chux0519 / pegasocks

A lightweight proxy client written in C, intends to support multiple protocols(trojan etc.)
BSD 3-Clause "New" or "Revised" License
117 stars 35 forks source link

udp support #9

Closed mokhtarabadi closed 3 years ago

mokhtarabadi commented 3 years ago

did you have any plan to implement socks5 UDP support like v2ray?

chux0519 commented 3 years ago

Thank you for your suggestion. You are the second person to mention UDP support. Yes, I will support socks5's UDP forwarding, and will increase its priority. Recently, I may do this feature first.

mokhtarabadi commented 3 years ago

Any news?

chux0519 commented 3 years ago

I'm working on some other projects recently, I will update this issue when I making any progress on this

mokhtarabadi commented 3 years ago

I test many v2ray clients, I found your client very smooth and light and use fewer resources when comparing to others for example v2fly or leaf, please continue the project and improve it by adding the below features: UDP support v2ray http2 support

I have an android VPN application, currently, I using v2fly (that has many unused features) in my app, which makes my app size big about 17 MB, but when I use your own project it decreases to 4 MB!

mokhtarabadi commented 3 years ago

also, add the ability to set sni and alpns for SSL (trojan & v2ray)

chux0519 commented 3 years ago

@mokhtarabadi Sorry for the late reply, I really appreciate for your words, I'm currently working on those features. You can checkout refactor branch, it's now support UDP ASSOCIATE for trojan-gfw(need more tests), and also support sni settings for trojan and v2ray, use ssl filed as an object, set ssl.sni, for example,

{
      "server_address": "1.0.0.1",
      "server_type": "v2ray",
      "server_port": 443,
      "password": "xxx-xxx-xxx-xxx-xxx",
      "ssl": {
        "sni": "xxx.com"
      },
      "websocket": {
        "path": "/xxxxx",
        "hostname": "xxx.com"
      }
    }

I will do the UDP support for v2ray next week maybe, and as for v2ray http2,I'm not interested in this and probably not implement it(at least at very low priority)

mokhtarabadi commented 3 years ago

I'm happy to see these I'll check it soon...

Also I have some more ideas: Shadowsocks support Fake dns support (also dns caching) HTTP inbound Set authentication for socks5

These will be useful but I think implement is hard, tuntap inbound using lwip library, so easily can transfer whole system traffic...

When v2ray udp will complete, I will make the android version

chux0519 commented 3 years ago

Haven't fully test it, but I think v2ray-udp should work now. I pushed to the refactor branch, you can try it.

I want the project to keep things simple, and focusing only on the socks5-proxy itself, so I think

and as for lwip things, maybe try to use tun2socks from badvpn will be easier.

mokhtarabadi commented 3 years ago

I see this error while running pegas in Kubuntu 21.04

[err] bufferevent.c:713: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_and_unlock_

also, the master branch produce this error too, but everything ok in manjaro KDE

chux0519 commented 3 years ago

Have you try to build the newest libevent from source, and see if it works. I think I hit the same error once when using some old version libevent

获取 Outlook for iOShttps://aka.ms/o0ukef


发件人: Mohammad Reza Mokhtarabadi @.> 发送时间: Saturday, July 31, 2021 6:50:42 PM 收件人: chux0519/pegasocks @.> 抄送: Yongsheng Xu @.>; Comment @.> 主题: Re: [chux0519/pegasocks] udp support (#9)

I see this error while building pegas in Kubuntu 21.04

[err] bufferevent.c:713: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_andunlock

also, the master branch produce this error too, but everything ok in manjaro KDE

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/chux0519/pegasocks/issues/9#issuecomment-890329318, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADM5S2QWAPSET32V2WWWCD3T2PIQFANCNFSM4XFALEGQ.

mokhtarabadi commented 3 years ago

Can you add static build support, so I can build dependencies from the source and link to pegas I don't know how I can edit cmake to doing this

chux0519 commented 3 years ago

@mokhtarabadi Actually you don't need to edit any thing, just build and install libevent from source

> git clone https://github.com/libevent/libevent.git
> cd libevent
> mkdir -p build && cd build
> cmake ..
> sudo make install

After that, libevent will be installed at /usr/local/lib header files will be found at /usr/local/include/event2

Then regenerate pegas cmake builds, and see what will happen, I remember that in the cmake script, the /usr/local/lib one is preferred.

And I think I will optimize cmake files later to support more options, like specify a specific version of libevent, static build etc. But before that, you can try above commands first, it might help.

mokhtarabadi commented 3 years ago

Hey @chux0519 , I built static binary by adding these lines to CmakeLists.txt

set(CMAKE_LIBRARY_PATH "../out/usr/local/lib"
set(CMAKE_INCLUDE_PATH "../out/usr/local/include;/..out/usr/local/include/json-c"
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")

also, I built all dependencies before from their source codes

mokhtarabadi commented 3 years ago

I tested it with badvpn-tun2socks, everything looks good, and it is stable for more than 24 hours, but I think the download/upload speed is slower than v2ray + tun2socks, I need to test more...

mokhtarabadi commented 3 years ago

after many tests, I found the problem is tun2socks, when I use go-tun2socks everything works great...

and one question @chux0519, will your vmess implementation also be affected by this v2ray changes in the future?

chux0519 commented 3 years ago

after many tests, I found the problem is tun2socks, when I use go-tun2socks everything works great...

and one question @chux0519, will your vmess implementation also be affected by this v2ray changes in the future?

yeah I think it's affected, I will take a closer look later.

chux0519 commented 3 years ago

@mokhtarabadi Since udp is supported I will close this issue. And as for the upcoming change of vmess, I will create a new issue for it. see https://github.com/chux0519/pegasocks/issues/13