Giter Club home page Giter Club logo

pegasocks's Introduction

pegasocks Cirrus CI Build Status

is a (socks5)proxy client written in C, intended to support multiple types of proxy protocols(trojan, v2ray, *shadowsock, ..). It is lightweight and supports unix-like systems(Linux/WSL/BSDs/OSX).

⚠️ This project is under development, please consider the cost and risk of use at your own discretion.

中文 | English

Features

Unlike most other clients that support multiple protocols, pegasocks does not rely on various third-party cores (e.g. v2ray-core, etc.), but really goes for the disassembly of the relevant protocols and takes care of performance as much as possible. Therefore it

  1. 🍃 is light enough that there are no QT or boost or other third-party binary dependencies.
  2. 🚀 Performance-first, with multiple worker threads by default, so theoretically higher throughput to be benchmarked)
  3. 🚥 This is a learn by doing project, feel free to review the code, provide optimization ideas and C programming related guidance.
  4. ❌ There is no GUI, you can directly work with systemd, launchd, rc or various custom scripts toconfigure the bootu.But you can optianly choose to build a simple tray indicator to interact with it, but in short, a heavy-duty GUI is not under consideration.

Dependencies

  • openssl 1.1.1 / mbedtls 2.27.0
  • libevent2.12 (on OSX, need the latest version)
  • pcre (lagacy) optional,will need it when ACL is enabled

Other dependencies are managed through git submodule, so you need to run following command after git clone.

git submodule update --init

Or add --recursive parameter in git clone command.

Install

If you use Arch Linux, you can install the latest version via AUR

yay -S pegasocks-git --overwrite /usr/local/bin/pegas,/usr/local/share/pegasocks/*

Or you can build it yourself as following

Build

mkdir build && cd build

cmake -DCMAKE_BUILD_TYPE=Release -DWITH_ACL=ON -DUSE_JEMALLOC=ON .. && make

Cmake Options

option meaning default
-DUSE_MBEDTLS Whether to use mbedtls instead of openssl OFF
-DUSE_JEMALLOC Whether to use jemalloc OFF
-DUSE_STATIC Whether to use static links OFF
-DWITH_ACL Whether to open ACL support (this will use more dependencies( libcork/ipset/PCRE ), so it will increase the final size of the program) OFF
-DWITH_APPLET Whether to enable system tray support (this will depend on some system libraries and will therefore increase the final size of the program) OFF

You can also customize the search root of JeMalloc/Libevent2/MbedTLS/OpenSSLx/PCRE with the following parameters.

-DOpenSSLx_ROOT=/xxxxxx/xxx/xxx for openssl root

-DLibevent2_ROOT=xxxxxx for libevent root

and so on

Run

pegas -c config.json -t 4

  • -c specifies the configuration file, by default it will try $XDG_CONFIG_HOME/.pegasrc or $XDG_CONFIG_HOME/pegas/config in order
  • -t specifies the number of worker threads, default is 4
  • -a specifies the ACL file if pegas is build with ACL feature

Configuration

see man page or wiki

Interaction

The "control_port" or "control_file" field of the configuration file can be used to open a TCP port or a unix socket to interact with the program. Use netcat / socat to interact with the relevant port or file.

  • GET SERVERS, which will return information about the server
  • SET SERVER $idx, which sets the current server

In linux socat demo

Also, the system tray is supported, see below

System Tray

Default compile binary without GUI, take parameter -DWITH_APPLET=ON to enable system tray.

cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPLET=ON . && make

Linux

To show the icon, put logo/icon.svg to where pegas sit.

OSX

On OSX, the binary will be packaged into an app bundle by default, just copy the packaged build/PegasApp.app to the application directly.

⚠️Note: If you encounter a situation where you can't start or hit a crash, please make sure that

  1. the latest libevent is installed in your system (do it manually, libevent2.12 from homebew will cause this issue)
  2. if there is a configuration file, the app bundle will detect ~/.config/.pegasrc or ~/.config/pegas/config

pegasocks's People

Contributors

chux0519 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  avatar  avatar  avatar  avatar  avatar

pegasocks's Issues

udp support

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

bug: vmess protocol

When the payload size exceeds the limit, it will fail the assertion

Assertion failed: (data_len + 2 <= _PGS_BUFSIZE), function pgs_vmess_write_body

MAC 设置系统代理后,Chrome无法访问网络。

启动PegasApp

config配置如下:

{
  "servers": [
    {
      "server_address": "13.94.62.160",
      "server_type": "v2ray",
      "server_port": 12021,
      "secure": "chacha20-poly1305",
      "password": "c31287ea-d8f1-3b37-9592-xxxx",
      "websocket": {
        "path": "/index",
        "hostname": "13.94.62.160"
      }
    }
  ],
  "local_address": "127.0.0.1",
  "local_port": 3080,
  "log_level": 0,
  "ping_interval":10
}

服务端信息:

{
    "host": "",
    "path": "/index",
    "tls": "",
    "verify_cert": true,
    "add": "13.94.62.160",
    "port": 12021,
    "aid": 2,
    "net": "ws",
    "headerType": "none",
    "v": "2",
    "type": "vmess",
    "ps": "A香港-✈ 上海联通",
    "remark": "A香港-✈ 上海联通",
    "id": "c31287ea-d8f1-3b37-9592-xxxx",
    "class": 1
}

托盘状态看上去连接正常:

7891633508887_ pic

设置系统代理

HTTP HTTPS SOCKS设置相同。都为127.0.0.1:3080
7871633507981_ pic_hd

Chrome无法打开网页

日志提示:”socks5: auth“。
日志位置如下:
pgs_session_error(session, "socks5: auth")

	switch (state) {
	case INBOUND_AUTH:
		len = evbuffer_get_length(input);
		rdata = evbuffer_pullup(input, len);
		if (len < 2 || rdata[0] != 0x5) {
			pgs_session_error(session, "socks5: auth");
			goto error;
		}
		evbuffer_add(output, "\x05\x00", 2);
		evbuffer_drain(input, len);
		session->inbound->state = INBOUND_CMD;
		return;

全部日志:

error: module importing failed: invalid pathname
2021-10-06 16:08:39.123645+0800 PegasApp[941:2542404] Metal API Validation Enabled
�[01;32m2021-10-06 16:08:38 [thread-3056] INFO: �[0mController Listening at: /tmp/pegas.sock
�[01;32m2021-10-06 16:08:38 [thread-5568] INFO: �[0mListening at 127.0.0.1:3080
�[01;32m2021-10-06 16:08:38 [thread-3056] INFO: �[0mcurrent server: 0, server length: 2
=================================================================
Main Thread Checker: UI API called on a background thread: -[NSStatusBarButton setImage:]
PID: 941, TID: 2542437, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   PegasApp                            0x000000010000d56f tray_update + 159
5   PegasApp                            0x000000010000d4c0 pgs_tray_update + 64
6   PegasApp                            0x0000000100018496 pgs_metrics_update + 38
7   PegasApp                            0x0000000100018841 on_v2ray_ws_g204_read + 529
8   PegasApp                            0x0000000100017ad2 on_v2ray_g204_read + 66
9   libevent-2.2.1.dylib                0x00000001003072ee bufferevent_run_deferred_callbacks_locked + 142
10  libevent-2.2.1.dylib                0x0000000100314645 event_process_active_single_queue + 1093
11  libevent-2.2.1.dylib                0x000000010031115f event_base_loop + 1951
12  PegasApp                            0x0000000100016871 pgs_helper_thread_start + 145
13  libsystem_pthread.dylib             0x00000001006ccc65 _pthread_start + 148
14  libsystem_pthread.dylib             0x00000001006c84af thread_start + 15
2021-10-06 16:08:40.096541+0800 PegasApp[941:2542437] [reports] Main Thread Checker: UI API called on a background thread: -[NSStatusBarButton setImage:]
PID: 941, TID: 2542437, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   PegasApp                            0x000000010000d56f tray_update + 159
5   PegasApp                            0x000000010000d4c0 pgs_tray_update + 64
6   PegasApp                            0x0000000100018496 pgs_metrics_update + 38
7   PegasApp                            0x0000000100018841 on_v2ray_ws_g204_read + 529
8   PegasApp                            0x0000000100017ad2 on_v2ray_g204_read + 66
9   libevent-2.2.1.dylib                0x00000001003072ee bufferevent_run_deferred_callbacks_locked + 142
10  libevent-2.2.1.dylib                0x0000000100314645 event_process_active_single_queue + 1093
11  libevent-2.2.1.dylib                0x000000010031115f event_base_loop + 1951
12  PegasApp                            0x0000000100016871 pgs_helper_thread_start + 145
13  libsystem_pthread.dylib             0x00000001006ccc65 _pthread_start + 148
14  libsystem_pthread.dylib             0x00000001006c84af thread_start + 15
�[01;32m2021-10-06 16:08:39 [thread-3056] DEBUG: �[0mconnect: 13.94.62.160:12021
�[01;32m2021-10-06 16:08:39 [thread-3056] DEBUG: �[0mconnect: cm.syhwdz.top:55945
�[01;32m2021-10-06 16:08:39 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:25823
�[01;32m2021-10-06 16:08:39 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:39 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:39 [thread-3056] DEBUG: �[0mdo_ws_remote_request
�[01;32m2021-10-06 16:08:39 [thread-3056] DEBUG: �[0mdo_ws_remote_request done
�[01;32m2021-10-06 16:08:40 [thread-3056] DEBUG: �[0mconnect: 234.000000
�[01;32m2021-10-06 16:08:40 [thread-3056] DEBUG: �[0mg204: 286.000000
�[01;32m2021-10-06 16:08:40 [thread-3056] DEBUG: �[0mconnect: 339.000000
�[01;32m2021-10-06 16:08:40 [thread-3056] DEBUG: �[0mg204 req sent: 134
�[01;32m2021-10-06 16:08:44 [thread-3056] DEBUG: �[0mg204: 4448.000000
�[01;32m2021-10-06 16:08:44 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:29407
�[01;32m2021-10-06 16:08:44 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:44 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:45 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:29663
�[01;32m2021-10-06 16:08:45 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:45 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mconnect: 13.94.62.160:12021
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mconnect: cm.syhwdz.top:55945
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mdo_ws_remote_request
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mdo_ws_remote_request done
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mconnect: 117.000000
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mg204: 160.000000
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mconnect: 179.000000
�[01;32m2021-10-06 16:08:49 [thread-3056] DEBUG: �[0mg204 req sent: 134
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:34271
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:34527
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:34783
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:35039
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:35295
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:35551
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:35807
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:36063
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:36319
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:36575
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:36831
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:37087
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:37343
�[01;32m2021-10-06 16:08:51 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:51 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:53 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:39135
�[01;32m2021-10-06 16:08:53 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:53 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:53 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:39391
�[01;32m2021-10-06 16:08:53 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:53 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:54 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:39647
�[01;32m2021-10-06 16:08:54 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:54 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:54 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:39903
�[01;32m2021-10-06 16:08:54 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:54 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:54 [thread-3056] DEBUG: �[0mg204: 4311.000000
�[01;32m2021-10-06 16:08:55 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:41695
�[01;32m2021-10-06 16:08:55 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:55 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:56 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:41951
�[01;32m2021-10-06 16:08:56 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:56 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:43231
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:57 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:43487
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:57 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:43743
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:57 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:43999
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:57 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:44255
�[01;32m2021-10-06 16:08:57 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:08:57 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:08:59 [thread-3056] DEBUG: �[0mconnect: 13.94.62.160:12021
�[01;32m2021-10-06 16:08:59 [thread-3056] DEBUG: �[0mconnect: cm.syhwdz.top:55945
�[01;32m2021-10-06 16:08:59 [thread-3056] DEBUG: �[0mdo_ws_remote_request
�[01;32m2021-10-06 16:08:59 [thread-3056] DEBUG: �[0mdo_ws_remote_request done
Printing description of rdata:
(uint8_t *) rdata = 0x000000010200fc30 "CONNECT gateway.icloud.com.cn:443 HTTP/1.1\r\nHost: gateway.icloud.com.cn\r\nUser-Agent: CloudKit/867 (19H2)\r\nConnection: keep-alive\r\nProxy-Connection: keep-alive\r\n\r\nbKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36\r\n\r\n"
�[01;32m2021-10-06 16:08:59 [thread-3056] DEBUG: �[0mconnect: 52.000000
�[01;32m2021-10-06 16:08:59 [thread-3056] DEBUG: �[0mg204: 84.000000
�[01;32m2021-10-06 16:09:00 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:46303
�[01;32m2021-10-06 16:09:00 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:09:00 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:48095
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:49887
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:50143
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:50399
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:50655
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:50911
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mnew client from port 127.0.0.1:53471
�[01;32m2021-10-06 16:09:18 [thread-5568] DEBUG: �[0mlocal tcp read triggered
Printing description of rdata:
(uint8_t *) rdata = 0x0000000102874030 "CONNECT api.twitter.com:443 HTTP/1.1\r\nHost: api.twitter.com\r\nUser-Agent: Twitter-Mac/8.82 iOS/13.6 (Apple;Macmini7,1;;;;;1;2021)\r\nConnection: keep-alive\r\nProxy-Connection: keep-alive\r\n\r\nChrome/93.0.4577.82 Safari/537.36\r\n\r\n36\r\n\r\n36\r\n\r\n"
�[01;31m2021-10-06 16:09:18 [thread-5568] ERROR: �[0msocks5: auth
�[01;32m2021-10-06 16:09:25 [thread-5568] DEBUG: �[0mlocal tcp read triggered
�[01;31m2021-10-06 16:09:25 [thread-5568] ERROR: �[0msocks5: auth
Printing description of rdata:
(uint8_t *) rdata = 0x0000000102867830 "CONNECT www.hxrtnt.com:443 HTTP/1.1\r\nHost: www.hxrtnt.com:443\r\nProxy-Connection: keep-alive\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36\r\n\r\n36\r\n\r\n"
(lldb) 

不清楚是配置有问题还是哪里有问题。

[Qustaion] can replace OpenSSL with WolfSSL?

It is possible?

The difference just is the final execution file size, a simple library with static linking OpenSSL is about 4-5Mb but with WolfSSL is about 500-700 Kb
This will be important In Android because Android not have shared OpenSSL and need to link it statically

pegasocks 移植到iOS ,访问百度正常,访问YouTube奔溃。

获取了203 commits最新的代码。libevent是最新分支代码。
访问百度 https://www.baidu.com正常。
访问YouTube https://www.youtube.com正常。

播放YouTube视频会奔溃,比如下面地址。

https://r4---sn-i3b7knzs.googlevideo.com/videoplayback?expire=1635935522&ei=whCCYfafGb-H1d8P3o65GA&ip=194.156.99.67&id=o-AIXCyTRCaW3ebf1mJUWRiems4M9pLoZKboX9-XBIsFBH&itag=18&source=youtube&requiressl=yes&mh=uM&mm=31%2C29&mn=sn-i3b7knzs%2Csn-i3belne6&ms=au%2Crdu&mv=m&mvi=4&pl=25&initcwndbps=545000&vprv=1&mime=video%2Fmp4&ns=tJpZGl_LZuQCH3NUaJL7UJgG&gir=yes&clen=1372314&ratebypass=yes&dur=24.055&lmt=1465824066677745&mt=1635913490&fvip=4&fexp=24001373%2C24007246&c=MWEB&n=folhUdYkaDaDqw&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIhALPKAmqifPnRdJodJ5EdMcNyPVeAoan00JNgJ0ZXJlf4AiAfd_YAtamovP4jaEPn5y9I3BFuU7bD_GkoYSBPqWC4wg%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgBNBfxdLVmDJHLXeXEwlDLlSqlfvxeU0UPmDza5QBagkCIE_oTTNMaaIWV07gz_D0cHplRqd6b1gTIQOxWSFxlrcv&cpn=uLiMR8Aaz8vf3r0W&cver=2.20211102.01.00&ptk=youtube_none&pltype=contentugc

iOS端主要代码改动如下:

			*(dns_base_ptr) = evdns_base_new(                       \
				(base), EVDNS_BASE_INITIALIZE_NAMESERVERS);     \

改为:

			*(dns_base_ptr) = evdns_base_new(                       \
				(base), EVDNS_BASE_NAMESERVERS_NO_DEFAULT);     \
                evdns_base_nameserver_ip_add(*(dns_base_ptr),"8.8.8.8"); \

奔溃点:

bufferevent.c:718: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_and_unlock_

bufev_private->refcnt会减小到0.

截屏2021-11-03 下午9 44 56

OSX build error

failed to link openssl 1.1( macos will link to libressl instead which is not right).

Making Android client

I want to make pegasocks Android client by using tun2socks, things I need are:

  1. RPC calling protect socket method in Android VPN Service from pegas like this and this, where is I need to implement these methods in pegasocks source?
  2. Tell Pegasocks to try to resolve remote domains from defined servers for example I want to have a running DoH client in 5353 port, and need to tell pegasocks to resolve remote domains by using 127.0.0.1:5353, maybe insert DNS option in the config?
  3. And this issue

Another scenario is to make pegasocks as a library and expose API headers, so I can easily integrate it with JNI and call it from Java code, this does not need the RPC callback anymore

(Before I make an pegasocks Android client with using built-in feature but this only works in Android 5+)

[Feature Request] add support for shadowsocks(R)

In Iran shadowsocks is very useful, did you have any plan to implement this?
because there is shadowsocks c version (libev) i think it can be done easily
also shadowsocksR is a good option, but not important

Mac 启动Crash: 0 failed in bufferevent_decref_and_unlock_

error: module importing failed: invalid pathname
�[01;32m2021-10-05 17:04:22 [thread-main] INFO: �[0mworker threads: 4, config: /Users/xxxx/.config/pegas/config
�[01;32m2021-10-05 17:04:22 [thread-3056] INFO: �[0mcurrent server: 0, server length: 2
�[01;32m2021-10-05 17:04:22 [thread-3056] INFO: �[0mController Listening at: /tmp/pegas.sock
�[01;32m2021-10-05 17:04:22 [thread-6896] INFO: �[0mListening at 0.0.0.0:1080
�[01;32m2021-10-05 17:04:22 [thread-3744] INFO: �[0mListening at 0.0.0.0:1080
�[01;32m2021-10-05 17:04:22 [thread-3472] INFO: �[0mListening at 0.0.0.0:1080
�[01;32m2021-10-05 17:04:22 [thread-0320] INFO: �[0mListening at 0.0.0.0:1080
[err] bufferevent.c:713: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_and_unlock_
Program ended with exit code: 9

Darwin Mac-mini.local 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Mac-mini-$ cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPLET=ON .. -G "Xcode"
-- The C compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found libevent2 includes: /usr/local/include/event2/event.h
-- Found libevent2 library: /usr/local/lib/libevent.dylib
-- Found libevent2 core library: /usr/local/lib/libevent_core.dylib
-- Found libevent2 extra library: /usr/local/lib/libevent_extra.dylib
-- Found libevent2 openssl library: /usr/local/lib/libevent_openssl.dylib
-- Found libevent2 mbedtls library: LIBEVENT2_MBEDTLS_LIBRARIES-NOTFOUND
-- Found openssl library root: /usr/local/Cellar/[email protected]/1.1.1l/
-- Found OpenSSL: /usr/local/Cellar/[email protected]/1.1.1l/lib/libcrypto.dylib (found suitable version "1.1.1l", minimum required is "1.1.0")
-- Found openssl libraries: /usr/local/Cellar/[email protected]/1.1.1l/lib/libssl.dylib;/usr/local/Cellar/[email protected]/1.1.1l/lib/libcrypto.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxxx/Desktop/Code/MyProject/pegasocks/build

Mac-mini-:build xxxx$ brew install libevent
Warning: libevent 2.1.12 is already installed and up-to-date.
To reinstall 2.1.12, run:
brew reinstall libevent

启动后crash

2020-12-16 10:50:55 [thread-main] INFO: worker threads: 4, config: config.json
2020-12-16 10:50:55 [thread-7808] INFO: Controller Listening at: /tmp/pegas.sock
2020-12-16 10:50:55 [thread-1408] INFO: Listening at 0.0.0.0:1080
2020-12-16 10:50:55 [thread-6432] INFO: Listening at 0.0.0.0:1080
2020-12-16 10:50:55 [thread-9136] INFO: Listening at 0.0.0.0:1080
2020-12-16 10:50:55 [thread-1840] INFO: Listening at 0.0.0.0:1080
[err] bufferevent.c:692: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_and_unlock_
已放弃 (核心已转储)

系统:#>uname -a
Linux xxx-911Pro 5.4.0-58-generic #64~18.04.1-Ubuntu SMP Wed Dec 9 17:11:11 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
libevent版本: libevent 2.1.12,因为libevent2.1.6版本也是如此,升级后问题如故。
openssl版本:1.1.1h;
未带WITH_APPLET编辑成功。

#>cmake ..
结果:
cmake ..
-- The C compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found libevent2 includes: /usr/include/event2/event.h
-- Found libevent2 library: /usr/lib/x86_64-linux-gnu/libevent.so
-- Found libevent2 core library: /usr/lib/x86_64-linux-gnu/libevent_core.so
-- Found libevent2 extra library: /usr/lib/x86_64-linux-gnu/libevent_extra.so
-- Found libevent2 openssl library: /usr/lib/x86_64-linux-gnu/libevent_openssl.so
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "1.1.1", minimum required is "1.1.0")
-- Found jsonc: /usr/include/json-c
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxx/Downloads/safra/pegasocks/build

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.