MCPcopy Index your code
hub / github.com/Sherlock-Holo/lycoris

github.com/Sherlock-Holo/lycoris @0.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.1 ↗ · + Follow
222 symbols 399 edges 46 files 12 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

lycoris

a bpf based proxy

currently, many proxy use http proxy or socks5 proxy protocol, all of them need the program support proxy protocol

actually this is a big limit, when you use some programs don't support specify the proxy, or it's very hard to enable the proxy, you will want to smash you computer :(

lycoris can solve this problem, at least solve the 95%

how it work

there are 3 parts about lycoris

  • lycoris-bpf
  • lycoris-client
  • lycoris-server

lycoris-bpf

lycoris-bpf will hook all socket connect, and check if the dst ip should be proxies or not, if it is a need proxy ip, lycoris-bpf will change the socket dst ip to lycoris-client, and save the real dst ip and port in bpf lru map, so lycoris-client can get it and send the dst ip and port to lycoris-server to connect the target

lycoris-client

lycoris-client will listen a tcp socket, when a new tcp accepted, it will try to get the real dst ip and port from bpf lru map, and send to lycoris-server

lycoris-server

lycoris-server is a simple proxy server, like camouflage, trojan or something else

the ip list file

it just a simple txt like

127.0.0.1/8
10.100.0.0/16

features

  • [x] TCP4 proxy
  • [ ] UDP4 proxy
  • [x] TCP6 proxy
  • [ ] UDP6 proxy
  • [x] ip list filter
  • [x] container proxy
  • need set container_bridge_listen_addr and container_bridge_listen_addr_v6
  • podman with slirp4netns doesn't need set, it connects tcp outside the container
  • docker need set, if use bridge+veth mode
  • [x] process comm filter

build

lycoris require nightly rust toolchain when build lycoris-bpf

build dependencies

  • rust toolchain
  • bpf-linker(can installed by cargo install)

just run cargo build --release

notes

  1. you can't build in the lycoris root dir, you should build inside bpf, client, server dir, because lycoris-bpf target is bpfel-unknown-none
  2. when build the lycoris-bpf, you must use release build mode, otherwise rustc and llvm will generate some instruction which will make bpf verifier unhappy

Extension points exported contracts — how you extend this code

Split (Interface)
(no doc) [2 implementers]
client/src/listener/mod.rs
FutureAbortExt (Interface)
(no doc) [1 implementers]
protocol/src/abort.rs
Ipv6AddrExt (Interface)
(no doc) [1 implementers]
share/src/helper.rs
LimitedBpfHashMap (Interface)
(no doc) [2 implementers]
client/src/addr/mod.rs
DnsResolver (Interface)
(no doc) [1 implementers]
protocol/src/lib.rs
ArrayExt (Interface)
(no doc)
share/src/helper.rs
Connect (Interface)
(no doc) [1 implementers]
client/src/connect/mod.rs
TcpConnector (Interface)
(no doc) [1 implementers]
protocol/src/connect.rs

Core symbols most depended-on inside this repo

get
called by 14
client/src/addr/mod.rs
remove
called by 8
client/src/addr/mod.rs
abortable
called by 8
protocol/src/abort.rs
network_order_segments
called by 8
share/src/helper.rs
accept
called by 7
client/src/listener/bpf.rs
init_log
called by 5
share/src/log.rs
abort
called by 4
protocol/src/abort.rs
encode_addr
called by 4
protocol/src/lib.rs

Shape

Function 87
Method 77
Class 44
Interface 10
Enum 4

Languages

Rust100%

Modules by API surface

protocol/src/accept.rs23 symbols
protocol/src/connect.rs17 symbols
client/src/lib.rs14 symbols
client/tests/proxy_v6.rs12 symbols
client/tests/proxy.rs12 symbols
client/src/addr/mod.rs12 symbols
share/src/tcp_wrapper.rs11 symbols
protocol/src/abort.rs10 symbols
protocol/src/hyper_body.rs8 symbols
protocol/src/auth.rs8 symbols
protocol/src/lib.rs7 symbols
share/src/proxy.rs6 symbols

For agents

$ claude mcp add lycoris \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact