Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/macronut/phantomsocks
A cross-platform proxy client/server for Linux/Windows/macOS
https://github.com/macronut/phantomsocks
Last synced: about 1 month ago
JSON representation
A cross-platform proxy client/server for Linux/Windows/macOS
- Host: GitHub
- URL: https://github.com/macronut/phantomsocks
- Owner: macronut
- License: lgpl-3.0
- Fork: true (A7610605/phantomsocks)
- Created: 2019-11-05T04:41:53.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T08:59:52.000Z (5 months ago)
- Last Synced: 2024-08-01T13:29:56.140Z (4 months ago)
- Language: Go
- Homepage:
- Size: 439 KB
- Stars: 444
- Watchers: 11
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - macronut/phantomsocks - A cross-platform proxy client/server for Linux/Windows/macOS (Go)
README
# phantomsocks
A cross-platform proxy client/server for Linux/Windows/macOS with Pcap/RawSocket/WinDivert
## Usage
```
./phantomsocks -h
Usage of ./phantomsocks:
-log int
LogLevel
-maxprocs int
MaxProcesses
-install
Install service (Windows)
-remove
Remove service (Windows)
-start
Start service (Windows)
-stop
Stop service (Windows)
```
## Configure
### config.json:
```
{
"vaddrprefix": 6,
"proxy": "socks://address:port",
"profiles": ["1.conf", "2.conf", "3.conf"],
"services": [
{
"name": "dns",
"protocol": "dns",
"address": "127.0.0.1:5353"
},
{
"name": "socks",
"protocol": "socks",
"address": "127.0.0.1:1081"
},
{
"name": "redirect",
"protocol": "redirect",
"address": "0.0.0.0:6"
},
{
"name": "tproxy",
"protocol": "tproxy",
"address": "0.0.0.0:6"
}
],
"interfaces": [
{
"name": "default",
"dns": "udp://8.8.8.8:53"
},
{
"name": "https",
"dns": "udp://8.8.8.8:53",
"device": "eth0",
"hint": "https"
},
{
"name": "doh",
"dns": "https://cloudflare-dns.com/dns-query"
},
{
"name": "dot",
"dns": "tls://8.8.8.8:853"
},
{
"name": "ecs",
"dns": "udp://8.8.8.8:53/?ecs=35.190.247.1"
},
{
"name": "socks5",
"protocol": "socks5",
"address": "127.0.0.1:1080"
},
{
"name": "socks4",
"dns": "udp://8.8.8.8:53",
"protocol": "socks4",
"address": "127.0.0.1:1080"
}
]
}
```
### Socks:
```
Windows:
config.json:
"proxy" :"socks://127.0.0.1:1080/?dns=127.0.0.1",
"services": [
{
"name": "DNS",
"protocol": "dns",
"address": "127.0.0.1:53"
},
{
"name": "Socks",
"protocol": "socks",
"address": "127.0.0.1:1080"
}
]macOS:
config.json:
"proxy": "socks://127.0.0.1:1080",
"services": [
{
"name": "Socks",
"protocol": "socks",
"address": "127.0.0.1:1080"
}
]
```
### Redirect:
```
Linux:
iptables -t nat -A OUTPUT -d 6.0.0.0/8 -p tcp -j REDIRECT --to-port 6
config.json:
"vaddrprefix": 6,
"services": [
{
"name": "DNS",
"protocol": "dns",
"address": "127.0.0.1:53"
},
{
"name": "Redirect",
"protocol": "redirect",
"address": "0.0.0.0:6"
}
]Windows(windivert):
config.json:
"vaddrprefix": 6,
"proxy": "redirect://0.0.0.0:6",
"services": [
{
"name": "Redirect",
"protocol": "redirect",
"address": "0.0.0.0:6"
}
]
```### Rules
```
[default] #domains below will use the config of this interface
domain=ip,ip,... #this domain will use these IPs
domain #this domain will be resolved by DNS
domain=[domain] #this domain will use the config of this domain
domain=domain #this domain will use the addresses of this domain
[dot] #domains below will use the config of dot
domain
[socks5] #domains below will use the config of socks5
domain
```
## Installation
go get github.com/macronut/phantomsocks## Compile
cd $GOPATH/src/github.com/macronut/phantomsocks/go build
### pcap version
static linking for pcap
```
sudo apt-get install -y libpcap-dev
go build -tags pcap -ldflags '-extldflags "-static"'
```
### raw socket version
raw socket is Linux only
```
go build -tags rawsocket
```
### windivert version
windivert is Windows only
```
env GOOS=windows GOARCH=amd64 go build -tags windivert
```### cross & static compile pcap version on Ubuntu 18.04
Install dependencies
```
apt-get install git autoconf automake bison build-essential flex gawk gettext gperf libtool pkg-config libpcap-dev
```
Download & uncompress tool-chain
```
cd ~/Downloads
wget https://downloads.openwrt.org/releases/19.07.2/targets/ramips/mt7621/openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz
tar -xJvf openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz
```
Set environment variable
```
export PATH=$PATH:~/Downloads/openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.5.0_musl/bin: && export STAGING_DIR=~/Downloads/openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.5.0_musl
```
Download & uncompress libpcap
```
wget https://www.tcpdump.org/release/libpcap-1.9.1.tar.gz
tar -xzvf libpcap-1.9.1.tar.gz
```
Build libpcap
```
cd libpcap-1.9.1
./configure --host=mipsel-openwrt-linux-musl --prefix='~/Downloads/openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.5.0_musl'
make && make install
```
Build phantomsocks
```
cd ~/go/src/github.com/Macronut/phantomsocks
env GOOS=linux GOARCH=mipsle CGO_ENABLED=1 CC='~/Downloads/openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.5.0_musl/bin/mipsel-openwrt-linux-gcc' go build -ldflags '-extldflags "-static"'
```