<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mojocn</title>
    <description>The latest articles on DEV Community by mojocn (@mojocn).</description>
    <link>https://dev.to/mojocn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F731911%2F5fbcdc3d-702d-4fe2-8568-aa9b6511816c.jpeg</url>
      <title>DEV Community: mojocn</title>
      <link>https://dev.to/mojocn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mojocn"/>
    <language>en</language>
    <item>
      <title>Unchain Proxy Svr By Golang</title>
      <dc:creator>mojocn</dc:creator>
      <pubDate>Fri, 27 Dec 2024 03:26:52 +0000</pubDate>
      <link>https://dev.to/mojocn/unchain-proxy-svr-by-golang-256i</link>
      <guid>https://dev.to/mojocn/unchain-proxy-svr-by-golang-256i</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/unchainese/unchain" rel="noopener noreferrer"&gt;Uchain&lt;/a&gt; is a lightweight and easy-to-use proxy server designed to bypass network restrictions, censorship, and surveillance effectively.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Protocol Support&lt;/strong&gt;: Seamlessly handles TCP and UDP (VLESS) packets over WebSocket with TLS/Cloudflare support.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Your Own VPN Business&lt;/strong&gt;: Provides a robust platform for starting your own VPN services.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility&lt;/strong&gt;: Fully compatible with popular proxy clients like v2rayN or any application supporting the VLESS + WebSocket protocol.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;Unchain operates as a proxy/VPN server, compatible with popular proxy clients such as v2rayN or any application that supports the VLESS+WebSocket protocol. It accepts traffic from various client applications, including:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/2dust/v2rayN" rel="noopener noreferrer"&gt;v2rayN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/v2rayA/v2rayA" rel="noopener noreferrer"&gt;v2rayA&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/Dreamacro/clash" rel="noopener noreferrer"&gt;Clash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/2dust/v2rayNG" rel="noopener noreferrer"&gt;v2rayNG&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://apps.apple.com/us/app/shadowrocket/id932747118" rel="noopener noreferrer"&gt;iOS app Shadowrocket&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unchain processes incoming traffic and securely forwards it to the destination server, ensuring both security and efficiency in communication.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Unchain Architecture
&lt;/h2&gt;

&lt;p&gt;Unchain is a dead simple VLESS over websocket proxy server.&lt;br&gt;
The core biz logic is only 200 lines of code.  &lt;a href="///internal/node/app_ws_vless.go"&gt;app_ws_vless.go&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unchain server uses a simple architecture that is VLESS over WebSocket (WS) + TLS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             V2rayN,V2rayA,Clash or ShadowRocket                          
                 +------------------+
                 |   VLESS Client   |
                 |   +-----------+  |
                 |   | TLS Layer  | |
                 |   +-----------+  |
                 |   | WebSocket  | |
                 |   +-----------+  |
                 +--------|---------+
                          |
                          | Encrypted VLESS Traffic (wss://)
                          |
           +--------------------------------------+
           |         Internet (TLS Secured)       |
           +--------------------------------------+
                          |
                          |
        +-----------------------------------+
        |        Reverse Proxy Server       |
        | (e.g., Nginx or Cloudflare)       |
        |                                   |
        |   +---------------------------+   |
        |   | HTTPS/TLS Termination     |   |
        |   +---------------------------+   |
        |   | WebSocket Proxy (wss://)  |   |
        |   +---------------------------+   |
        |     Forward to VLESS Server       |
        +------------------|----------------+
                           |
           +--------------------------------+
           |     Unchain       Server       |
           |                                |
           |   +------------------------+   |
           |   | WebSocket Handler      |   |
           |   +------------------------+   |
           |   | VLESS Core Processing  |   |
           |   +------------------------+   |
           |                                |
           |   Forward Traffic to Target    |
           +------------------|-------------+
                              |
                     +-----------------+
                     | Target Server   |
                     | or Destination  |
                     +-----------------+

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Build from Source
&lt;/h3&gt;

&lt;p&gt;To build from source, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repository and navigate to the &lt;code&gt;cmd/node&lt;/code&gt; directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;cd &lt;/span&gt;cmd/node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Copy the example configuration file and customize it:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;cp &lt;/span&gt;config.example.standalone.toml config.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Run the application:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Deploying on Your Own Ubuntu Server Using GitHub Actions
&lt;/h3&gt;

&lt;p&gt;You can deploy the application on an Ubuntu server using GitHub Actions. Here's how:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fork the repository&lt;/strong&gt; to your GitHub account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create an Environment&lt;/strong&gt; named &lt;code&gt;production&lt;/code&gt; in your repository settings.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the following SSH connection details&lt;/strong&gt; to the Environment Secrets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;EC2_HOST&lt;/code&gt;: The SSH host with port (e.g., &lt;code&gt;1.1.1.1:20&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EC2_USER&lt;/code&gt;: The SSH user (e.g., &lt;code&gt;ubuntu&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EC2_KEY&lt;/code&gt;: Your SSH private key.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add your TOML configuration file content&lt;/strong&gt; to the Environment Variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CONFIG_TOML&lt;/code&gt;: Copy the content of your &lt;code&gt;config.toml&lt;/code&gt; file, replace all &lt;code&gt;"&lt;/code&gt; with &lt;code&gt;'&lt;/code&gt;, and paste it here.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;learn more in &lt;a href="///.github/workflows/deploy.sh"&gt;.github/workflows/deploy.sh&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Running the Application
&lt;/h3&gt;

&lt;p&gt;Once the application is running, you will see a VLESS connection schema URL in the standard output. Copy and paste this URL into your V2rayN client.&lt;/p&gt;

&lt;p&gt;Congratulations! You now have your self-hosted proxy server up and running.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. (Optional) create your own admin app for Auth and Data-traffic
&lt;/h3&gt;

&lt;p&gt;create an RESTful API for &lt;a href="https://github.com/unchainese/unchain/blob/5ece8c39814684a8a54e8e009d7c888e5988a017/internal/node/app.go#L161" rel="noopener noreferrer"&gt;chain proxy server push&lt;/a&gt; :&lt;br&gt;
&lt;a href="https://github.com/unchainese/unchainadmin/blob/035b2232d4262c24ef70b8ad7abb9faebaaecc96/functions/api/nodes.ts#L34" rel="noopener noreferrer"&gt;Register API example code&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Build your own VPN business
&lt;/h2&gt;

&lt;p&gt;Using &lt;a href="https://github.com/unchainese/unchainadmin" rel="noopener noreferrer"&gt;the cloudflare page UnchainAdmin&lt;/a&gt; start your own VPN business. &lt;/p&gt;

</description>
      <category>go</category>
      <category>v2ray</category>
      <category>proxy</category>
      <category>websocket</category>
    </item>
  </channel>
</rss>
