Giter Club home page Giter Club logo

smartsni's Introduction

Smart SNI and DNS Proxy Server

This DNS Proxy Server is a Go-based server capable of handling both DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT) requests. It features rate limiting and can process DNS queries based on a custom JSON configuration file.

Features

  • DNS-over-HTTPS (DoH): Accepts and processes DNS queries over HTTPS.
  • DNS-over-TLS (DoT): Accepts and processes DNS queries over TLS.
  • Rate Limiting: Throttles the number of requests using a limiter.
  • Custom Domain Handling: Matches DNS queries to a list of specified domains and returns corresponding IP addresses.
  • SNI Proxy: Proxies non-matching domains to their respective addresses.
  • Configurable: Uses a config.json file to define behavior for specified domains.

Configuration

The server uses a config.json file which should be structured as follows:

{
  "host": "your.host.com",
  "domains": {
    "example.com": "1.2.3.4",
    "anotherdomain.com": "1.2.3.4"
  }
}

Replace the IP addresses with your server's public IP to ensure transparent proxying(Here it's 1.2.3.4).

You can use this code to proxy all domains(its not recommended)

{
  "host": "your.host.com",
  "domains": {
    ".": "1.2.3.4"
  }
}

TLS Certificates

The DoT and DOH servers expect TLS certificates to be located at /etc/letsencrypt/live/your.host.com/. Make sure you have valid certificates named fullchain.pem and privkey.pem.

You can obtain a valid certificate for your domain with lets encrypt

Auto Install

bash <(curl -fsSL https://raw.githubusercontent.com/bepass-org/smartSNI/main/install.sh)

Manual Setup

  1. Install Requirements
apt update
apt install nginx certbot python3-certbot-nginx
snap install go --classic
  1. Change server_name in /etc/nginx/sites-enabled/default to your domain
  2. Obtain a valid certificate for nginx
certbot --nginx -d <YOUR_DOMAIN>
  1. Clone the repository to your local machine.
  2. Create and configure your config.json file.
  3. Run go build to compile the server.
  4. Run the compiled binary to start the server in tmux or in background with nohup.
./name-of-compiled-binary

Rate Limiting

The server uses the golang.org/x/time/rate package to implement rate limiting. You can adjust the rate limiter in the main function to suit your needs.

Contributions

Contributions to this project are welcome. Please fork the repository, make your changes, and submit a pull request.

Credits

Special thanks to Peyman for auto install script

License

This project is open-source and available under the MIT License.

smartsni's People

Contributors

ptechgithub avatar uoosef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

smartsni's Issues

لیست سایت های تحریم کننده ایران

ادیت: لیست بروز اینجا:

https://gist.github.com/asefsoft/eee71f3df313cbf50b8c7a90278df71f

دوستان اینجا میخوایم لیست سایت هایی که IP‌ ایران رو تحریم کردن رو تکمیل کنیم و بزاریم توی برنامه تا ابنها برامون از سرور خودمون پروکسی بشن.

من یک لیستی رو آماده کردم اما قطعا موارد زیاد دیگه ای هم هست که ازتون میخوام تا مشارکت کنید تا تکمیلش کنیم:


{
  "host": "<YOUR_HOST>",
  "domains": {
    "analytics.google.com": "<YOUR_IP>",
    "firebaseremoteconfig.googleapis.com": "<YOUR_IP>",
    "cloud.google.com": "<YOUR_IP>",
    "ads.google.com": "<YOUR_IP>",
    "fonts.googleapis.com": "<YOUR_IP>",
    "developer.android.com": "<YOUR_IP>",
    "console.cloud.google.com": "<YOUR_IP>",
    "googletagmanager.com": "<YOUR_IP>",
    "cloud.oracle.com": "<YOUR_IP>",
    "oraclecloud.com": "<YOUR_IP>",
    "adobe.com": "<YOUR_IP>",
    "hpe.com": "<YOUR_IP>",
    "thwack.solarwinds.com": "<YOUR_IP>",
    "slack.com": "<YOUR_IP>",
    "downloadcenter.intel.com": "<YOUR_IP>",
    "corpredirect.intel.com": "<YOUR_IP>",
    "ark.intel.com": "<YOUR_IP>",
    "oriondemo.solarwinds.com": "<YOUR_IP>",
    "www.algolia.com": "<YOUR_IP>",
    "download-ssc.cisco.com": "<YOUR_IP>",
    "api.cisco.com": "<YOUR_IP>",
    "software.cisco.com": "<YOUR_IP>",
    "i.ytimg.com": "<YOUR_IP>",
    "firebaseextensions.clients6.google.com": "<YOUR_IP>",
    "repo.mysql.com": "<YOUR_IP>",
    "pcsupport.lenovo.com": "<YOUR_IP>",
    "firebase.google.com": "<YOUR_IP>",
    "packages.cloud.google.com": "<YOUR_IP>",
    "apt.kubernetes.io": "<YOUR_IP>",
    "developers.google.com": "<YOUR_IP>",
    "chat.openai.com": "<YOUR_IP>",
    "claude.ai": "<YOUR_IP>",
    "chat.claude.ai": "<YOUR_IP>",
    "linuxhostsupport.com": "<YOUR_IP>",
    "pastebin.com": "<YOUR_IP>",
    "atlassian.net": "<YOUR_IP>",
    "dgivdslhqe3qo.cloudfront.net": "<YOUR_IP>",
    "d36jcksde1wxzq.cloudfront.net": "<YOUR_IP>",
    "d2wy8f7a9ursnm.cloudfront.net": "<YOUR_IP>",
    "d20hvw4zeymqbm.cloudfront.net": "<YOUR_IP>",
    "vmware.com": "<YOUR_IP>",
    "intel.com": "<YOUR_IP>",
    "intel.de": "<YOUR_IP>",
    "docker.com": "<YOUR_IP>",
    "amd.com": "<YOUR_IP>",
    "lenovo.com": "<YOUR_IP>",
    "ebay.com": "<YOUR_IP>",
    "oracle.com": "<YOUR_IP>",
    "arcgis.com": "<YOUR_IP>",
    "spiceworks.com": "<YOUR_IP>",
    "ebaystatic.co": "<YOUR_IP>",
    "ebayimg.com": "<YOUR_IP>",
    "ebaycdn.net": "<YOUR_IP>",
    "solarwinds.com": "<YOUR_IP>",
    "gns3.com": "<YOUR_IP>",
    "motorola.com": "<YOUR_IP>",
    "visa.com": "<YOUR_IP>",
    "visa.de": "<YOUR_IP>",
    "ti.com": "<YOUR_IP>",
    "adobe.com": "<YOUR_IP>",
    "att.com": "<YOUR_IP>",
    "nvidia.com": "<YOUR_IP>",
    "gitlab.com": "<YOUR_IP>",
    "grafana.com": "<YOUR_IP>",
    "registry.docker.io": "<YOUR_IP>"
  }
}

support ECH

سلام بر مهندس یوسف عزیز
آقا نمیشه ی کاری کرد که ECH رو توی مروگر فعال کنیم و با استفاده از این doh درخواست ها هندل بشن ؟
چون sni که انکریپت بشه دیگه فیلتر sni بی معنی میشه از طرفی ایپی هم که تغییر دادیم باید بدون مشکل باز کنه همه چی رو و دیگه نیازی به vpn هم نداشته باشیم

فروارد کردن tcp و udp

سلام
خسته نباشی عزیز
یه درخواستی داشتم
اینکه مثلا کل ترافیکی که مثلا با هدر هاست google.com میاد
با هر پورت و پروتوکلی
اونو فروارد کنه به سرور اصلی گوگل
اینجوری همه چی با این dns ردیف میشه
حتی بازی های آنلاین هم با این dns بالا میان و راحت میشه سرویسی شبیه به رادار گیم ساخت
موردی بود داخل تلگرام در خدمتتم
https://t.me/rezakhan8

پیشنهاد در مورد AdGuardHome

سلام خسته نباشید
من قبلا خودم برای راه اندازی dns اختصاصی از AdGuardHome استفاده میکردم که بسیار تمیز ساخته شده و امکانات خیلی جالبی داره
تنها چیزی که کم داره sni proxy هست . نمیشه این رو fork کرد بهش فقط sni proxy اضافه کنیم ؟
چون هم پنل خیلی خوبی داره و هم خیلی از چیز هایی که لازم داریم از قبل روش فکر شده و باگ هاش گرفته شده داخل این پروژه
با زبان Go هم زده شده

https://github.com/AdguardTeam/AdGuardHome

image

حل مشکل درخواست هایی که پورت 443 نیستن

سلام وقت بخیر مهندس عزیز
یه مشکلی که الان هست اینه که فقط از پورت 443 پشتیبانی میکنه
چون خیلی از سایت ها هستن که دارن از ws استفاده میکنن و روی پورت 443 نیست اون کانکشن و اینجا به مشکل میخوره
برای مثال همین speedtest :

wss://speedtest.pfalzkom.de.prod.hosts.ooklaserver.net:8080/ws?

یا به هر دلیلی ممکن هست پورت 443 نباشه
بهترین راه این هست که تمامی پورت ها رو به 443 ریدایرکت کنیم ولی خب پورت اصلی گم میشه . ولی ظاهرا میشه با خوندن جدول nat پورت اصلی رو پیدا کرد که توضیح کاملش در این لینک هست
https://blog.snix.ir/posts/goshkan-proxy-server

ممنون میشم اینم درست کنید که دیگه برنامه کامل باشه

how to use dns on macOS?

Hi, I used to use macOS but recently I need to use dns so I have configured my own dns for firefox and google chrome but I can't use my dns on macOS. Can anyone help me?

Sni service 'not active'

سلام دوستان.تو سرور من پروسه نصب کامل تااخر انجام میشه.منتها اخرش مینویسه، "not active" وکارنمیکنه.
فایل کانفیگ چک کردم، دیدم بجای ایپی dns م، 127.0.0.1 نوشته شده! که وقتی اونم به ایپی سرورم تغییر میدم، بازم سرویس کارنمیکنه! چطورمیشه رفع کرد مشکل، خیلی باین سرویس نیازدارم.
InShot_20231214_183712719

مشکل وصل نشدن به سرور بازی های آنلاین

سلام ، خسته نباشید
من تونستم توسط این اسکریپت و adguard home به صورت ipv4 یک dns بسازم
مشکلی در راستای وصل شدن به سایت هایی که تحریم هستیم ندارم و سرعت و همه چیز اوکیه
مشکلم سر وصل شدن به سرور های بازی های آنلاین هست که اصلا وصل نمیشه
اگه کسی راه حلی داره ممنون میشم راهنمایی بکنه

راهنمایی بابت باز کردن سرویس های خاص

با سلام و احترام؛ ضمن تشکر و خسته نباشید. من از اسکریپت استفاده کردم و تونستم بخش زیادی از سرویس هارو باز کنم.
سوالی که داشتم در ارتباط با سرویس هایی بود که متفاوت مارو تحریم کردند. 2 نمونه مثال می زنم.
مثلا chatgpt یا سرویس های گوگل (مثل گوگل ارت)
ممنون میشم راهنمایی کنید که سرویس های dns ایرانی به چه صورتی این سرویس هارو باز می کنند و با چه راه حلی می تونیم از سرویس شما برای بازگشایی این نوع سرویس ها بهره ببریم. با تشکر از شما

حل مشکل 502 در آدرس های http

برای حل این مشکل نیاز هست که یک resolver برای پورت 80 در تنظیمات nginx اضافه بشود:

/etc/nginx/sites-enabled/default

server {
    listen 80 default_server;
    server_name _;
    ...
    location / {
      resolver                1.1.1.1;
      ...
      proxy_pass          http://$host:80;
    }

پورت

از چه پورتی روی سرور استفاده میکنه؟

استفاده از dns به جای آدرس دامنه برای دور زدن تحریم کنسولهای بازی مثل ایکس باکس و ps5

با عرض سلام خدمت دوستان گرامی

اسکریپت بسیار عالی کار میکنه منتها مشکل اینه تو کنسولهای بازی مثل ایکس باکس و پلی استیشن فقط میشه از dns برای دور زدن تحریم استفاده کرد . در مورد ایکس باکس که کاملا تحریم هستیم و بدون dns اصلا نمیشه به سایت و سرورهای مایکروسافت وصل شد .

سوالم اینه راه حلی وجود داره که بعد از نصب اسکریپت به جای استفاده از دامنه بشه از dns اختصاصی استفاده کنیم ؟ مثلا بشه مثل حالت فعلی آدرس سایتها و سرورهای بازی رو به فهرست اضافه کنیم اما از اون طرف به جای دامنه از dns اختصاصی استفاده کنیم .
چون متاسفانه dns های رایگان کیفیت خوبی ندارند و یا اینکه روی همه سرویسهای اینترنتی جواب نمیدن .

با تشکر

Server list

آیا امکانش هست که همه سایت ها رو از این طریق استفاده کنیم، برای پلی استیشن و بازی هاش رو نمیشه به راحتی یکی یکی پیدا کرد و لیست کرد

ویرایش سایت ها

سلام یوسف جان ممنون از کار جالبت

مستندات یکم گنگ هست و من به مشکل خوردم. الان من از طریق نصب اتومات نصبش کردم و وقتی میخوام سایت جدید اضافه کنم نمیدونم دقیقا کجا باید اضافه کنم. آیا مسیرش همین

/root/smartSNI/config.json

هستش؟
من اینجا رو ویرایش کردم اما اعمال نمیشه. سرویس های sni و nginix‌رو هم ریستارت کردم اما اعمال نمیشه انگار

Error in installation

i tried to install thru CentOS 7, but i get the below error message:

Enter the domain names separated by commas (example: google,youtube): intel.com sed: can't read /etc/nginx/sites-enabled/default: No such file or directory sed: can't read /root/smartSNI/nginx.conf: No such file or directory Saving debug log to /var/log/letsencrypt/letsencrypt.log The requested nginx plugin does not appear to be installed cp: cannot stat ‘/root/smartSNI/nginx.conf’: No such file or directory The SNI service is now active

what should i do?

عدم کارکرد

سلام و خسته نباشید.
من از طریق اسکریپت نصب اتوماتیک ، Smart SNI رو نصب کردم ( قبلا دستی نصب کردم ولی نتونستم استفاده کنم درحالی که همه چی اوکی بود )
اما بعد از طی همه ی مراحل ، بازم نتونستم ازش استفاده کنم

دامین چک شده فیلتر نیست
آیپی آزاده و فیلتر نیست
سرور از هتزنره

تست روی DoT برای اندرویده و ارور Couldn't Connect میده.
روی سرور هم کلا فایروال فعال نیست و همه ی پورتا به صورت پیش فرض بازن.

ممکنه خود هتزنر پورتایی که DNS لازم داره رو بسته باشه؟
یا اینکه اگه نکته ای داره نصبش لطفا بگید.
مثلا چه پورتایی استفاده میشه و حتما باید باز باشه و .....

ممنونم

اضافه کردن آیپی به جای سایت

سلام. dns بیشتر برای استفاده از بازی هست تا رد شدن از سایت های فیلتر شده. و اکنون موردی که پیش اومده میخوام رنج آیپی بازی پابجی رو به لیست اضافه کنم اما نمیدونم چجوری

درخواست ساخت داکر

با سلام اگر لطف کنید و این رو بصورت داکر هم رائه بدهید ممنون میشم. من روی سرورم کانفیگ های زیادی دارم . همین الان انجین ایکس دارم . میترسم اینو نصب کنم کانفلیکت های صورت بگیره . اگر داکر باشه خیالم جمعه . متشکر و ممنون

OS is not mentioned

من روی CentOS سعی کردم نصب کنم نشید، روی چه سروری باید نصب بشه؟

همه ادرس ها

سلام . این خیلی سخت یا نا ممکنه که بشه فهمید مثلا فلان بازی روی اندورید داره از چه دامنه هایی استفاده میکنه که اونها رو تو کانفیگ وارد کنیم !!! این شاید ناممکن باشه . اگر راهی باشه که ترافیک همه دامنه ها رو به ای پی تبدیل کنه خیلی بهتر ازینه که فقط چند تا دامنه رو بخواهیم دستی بزنیم. اگر راهی داره لطفا راهنمایی فرمایید . ممنون

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.