Documentation
¶
Index ¶
- Constants
- Variables
- func AddConn(synAddr string, option uint32)
- func AddDNSLie(name string, pface *PhantomInterface) uint32
- func ComputeUDPChecksum(buffer []byte) uint16
- func ConnectionMonitor(devices []string) bool
- func CreateInterfaces(Interfaces []InterfaceConfig) []string
- func DNSTCPServer(client net.Conn)
- func DelConn(synAddr string)
- func DevicePrint()
- func DialTCP(address string, device string) (net.Conn, error)
- func DialUDP(address string) (net.Conn, error)
- func DoHServer(w http.ResponseWriter, req *http.Request)
- func GetAddressFromInterface(iface string, ipv6 bool) (string, error)
- func GetHeader(conn net.Conn) ([]byte, error)
- func GetHelloLength(header []byte) int
- func GetHost(b []byte) (offset int, length int)
- func GetLocalAddr(name string, ipv6 bool) (*net.TCPAddr, error)
- func GetName(buf []byte, offset int) (string, int)
- func GetNameOffset(response []byte, offset int) int
- func GetOriginalDST(conn *net.TCPConn) (*net.TCPAddr, error)
- func GetPAC(address string, profile string) string
- func GetQName(buf []byte) (string, int, int)
- func GetQUICSNI(b []byte) string
- func GetQUICVersion(data []byte) uint32
- func GetSNI(header []byte) (offset int, length int, ech bool)
- func HTTPProxy(client net.Conn)
- func HTTPSlookup(request []byte, u *url.URL, domain string) ([]byte, error)
- func HttpMove(conn net.Conn, host string, b []byte) bool
- func IsAddressInUse(err error) bool
- func IsIPv6(addr string) bool
- func IsNormalError(err error) bool
- func ListenUDP(address string) (*net.UDPConn, error)
- func LoadHosts(filename string) error
- func LoadProfile(filename string) error
- func ModifyAndSendPacket(connInfo *ConnectionInfo, payload []byte, hint uint32, ttl uint8, count int) error
- func NSRequest(request []byte, cache bool) (uint32, []byte)
- func Netcat(client net.Conn)
- func PackQName(name string) []byte
- func PackRequest(name string, qtype uint16, id uint16, ecs string) []byte
- func QUICProxy(address string)
- func ReadAtLeast()
- func Redirect(dst string, to_port int, forward bool)
- func RedirectDNS()
- func RedirectProxy(client net.Conn)
- func SNIProxy(client net.Conn)
- func SendWithOption(conn net.Conn, payload []byte, tos int, ttl int) error
- func SocksProxy(client net.Conn)
- func SocksUDPProxy(address string)
- func StoreDNSCache(qname string, records *DNSRecords)
- func TCPMapping(Listener net.Listener, Hosts string) error
- func TCPlookup(request []byte, address string, server *PhantomInterface) ([]byte, error)
- func TCPlookupDNS64(request []byte, address string, offset int, prefix []byte) ([]byte, error)
- func TFOlookup(request []byte, address string) ([]byte, error)
- func TLSFragment(header []byte, frag_size int) []byte
- func TLSlookup(request []byte, address string) ([]byte, error)
- func TProxyUDP(address string)
- func UDPMapping(Address string, Target string) error
- func UDPlookup(request []byte, address string) ([]byte, error)
- type ConnectionInfo
- type DNSLie
- type DNSRecords
- type IPv4Range
- type IPv6Range
- type InterfaceConfig
- type Peer
- type PhantomInterface
- func (pface *PhantomInterface) Dial(conn net.Conn, host string, port int, b []byte) (net.Conn, *ConnectionInfo, error)
- func (pface *PhantomInterface) DialStrip(host string, fronting string) (*tls.Conn, error)
- func (pface *PhantomInterface) DialTCP(address *net.TCPAddr) (net.Conn, error)
- func (pface *PhantomInterface) DialUDP(address *net.UDPAddr) (net.Conn, error)
- func (pface *PhantomInterface) DialUDPProxy(host string, port int) (net.Conn, net.Conn, error)
- func (pface *PhantomInterface) GetRemoteAddresses(host string, port int) ([]*net.TCPAddr, error)
- func (server *PhantomInterface) Keep(client, conn net.Conn, connInfo *ConnectionInfo)
- func (pface *PhantomInterface) NSLookup(name string) (uint32, []net.IP)
- func (pface *PhantomInterface) ProxyHandshake(conn net.Conn, synpacket *ConnectionInfo, host string, port int, header []byte) (net.Conn, error)
- func (pface *PhantomInterface) ResolveTCPAddr(host string, port int) (*net.TCPAddr, error)
- func (pface *PhantomInterface) ResolveTCPAddrs(host string, port int) ([]*net.TCPAddr, error)
- type PhantomProfile
- type RecordAddresses
- type ServerOptions
- type ServiceConfig
- type SynInfo
Constants ¶
View Source
const ( DIRECT = 0x0 REDIRECT = 0x1 NAT64 = 0x2 HTTP = 0x3 HTTPS = 0x4 SOCKS4 = 0x5 SOCKS5 = 0x6 )
View Source
const ( HINT_NONE = 0x0 HINT_ALPN = 0x1 << 1 HINT_HTTPS = 0x1 << 2 HINT_HTTP2 = 0x1 << 3 HINT_HTTP3 = 0x1 << 4 HINT_IPV4 = 0x1 << 5 HINT_IPV6 = 0x1 << 6 HINT_MOVE = 0x1 << 7 HINT_STRIP = 0x1 << 8 HINT_FRONTING = 0x1 << 9 HINT_TTL = 0x1 << 10 HINT_WMD5 = 0x1 << 11 HINT_NACK = 0x1 << 12 HINT_WACK = 0x1 << 13 HINT_WCSUM = 0x1 << 14 HINT_WSEQ = 0x1 << 15 HINT_WTIME = 0x1 << 16 HINT_TFO = 0x1 << 17 HINT_UDP = 0x1 << 18 HINT_NOTCP = 0x1 << 19 HINT_DELAY = 0x1 << 20 HINT_MODE2 = 0x1 << 21 HINT_DF = 0x1 << 22 HINT_SAT = 0x1 << 23 HINT_RAND = 0x1 << 24 HINT_SSEG = 0x1 << 25 HINT_1SEG = 0x1 << 26 HINT_TLSFRAG = 0x1 << 27 HINT_HTFO = 0x1 << 28 HINT_KEEPALIVE = 0x1 << 29 HINT_SYNX2 = 0x1 << 30 HINT_ZERO = 0x1 << 31 )
View Source
const ( SO_ORIGINAL_DST = 80 IP6T_SO_ORIGINAL_DST = 80 )
View Source
const HINT_DNS = HINT_ALPN | HINT_HTTPS | HINT_HTTP2 | HINT_HTTP3 | HINT_IPV4 | HINT_IPV6
View Source
const HINT_FAKE = HINT_TTL | HINT_WMD5 | HINT_NACK | HINT_WACK | HINT_WCSUM | HINT_WSEQ | HINT_WTIME
View Source
const HINT_MODIFY = HINT_FAKE | HINT_SSEG | HINT_1SEG | HINT_TLSFRAG | HINT_TFO | HINT_HTFO | HINT_MODE2 | HINT_MOVE | HINT_STRIP | HINT_FRONTING
Variables ¶
View Source
var ConnInfo4 [65536]chan *ConnectionInfo
View Source
var ConnInfo6 [65536]chan *ConnectionInfo
View Source
var ConnSyn sync.Map
View Source
var DNSCache map[string]*DNSRecords = make(map[string]*DNSRecords)
View Source
var DNSCacheMutex sync.RWMutex
View Source
var DNSMinTTL uint32 = 0
View Source
var DNSRecordMutex sync.RWMutex
View Source
var Forward bool = false
View Source
var HintMap = map[string]uint32{ "none": HINT_NONE, "https": HINT_HTTPS, "h2": HINT_HTTP2, "h3": HINT_HTTP3, "ipv4": HINT_IPV4, "ipv6": HINT_IPV6, "move": HINT_MOVE, "strip": HINT_STRIP, "fronting": HINT_FRONTING, "udp": HINT_UDP, "no-tcp": HINT_NOTCP, "delay": HINT_DELAY, "s-seg": HINT_SSEG, "1-seg": HINT_1SEG, "tls-frag": HINT_TLSFRAG, }
View Source
var InterfaceMap map[string]*PhantomInterface
View Source
var LogLevel = 0
View Source
var Logger *log.Logger
View Source
var Nose []DNSLie = []DNSLie{{"phantom.socks", nil}}
View Source
var NoseLock sync.Mutex
View Source
var PassiveMode = false
View Source
var SubdomainDepth = 2
View Source
var TFOCookies sync.Map
View Source
var TFOPayload [64][]byte
View Source
var TFOSynID uint8 = 0
View Source
var VirtualAddrPrefix byte = 255
Functions ¶
func AddDNSLie ¶
func AddDNSLie(name string, pface *PhantomInterface) uint32
func ComputeUDPChecksum ¶
func ConnectionMonitor ¶
func CreateInterfaces ¶
func CreateInterfaces(Interfaces []InterfaceConfig) []string
func DNSTCPServer ¶
func DevicePrint ¶
func DevicePrint()
func GetAddressFromInterface ¶
func GetHelloLength ¶
func GetNameOffset ¶
func GetQUICSNI ¶
func GetQUICVersion ¶
func IsAddressInUse ¶
func IsNormalError ¶
func LoadProfile ¶
func ModifyAndSendPacket ¶
func ReadAtLeast ¶
func ReadAtLeast()
func RedirectDNS ¶
func RedirectDNS()
func RedirectProxy ¶
func SocksProxy ¶
func SocksUDPProxy ¶
func SocksUDPProxy(address string)
func StoreDNSCache ¶
func StoreDNSCache(qname string, records *DNSRecords)
func TCPlookup ¶
func TCPlookup(request []byte, address string, server *PhantomInterface) ([]byte, error)
func TCPlookupDNS64 ¶
func TLSFragment ¶
func UDPMapping ¶
Types ¶
type ConnectionInfo ¶
func DialConnInfo ¶
func DialConnInfo(laddr, raddr *net.TCPAddr, pface *PhantomInterface, payload []byte) (net.Conn, *ConnectionInfo, error)
type DNSLie ¶
type DNSLie struct { Name string Interface *PhantomInterface }
type DNSRecords ¶
type DNSRecords struct { Index uint32 ALPN uint32 IPv4Hint *RecordAddresses IPv6Hint *RecordAddresses CName string Ech []byte }
func LoadDNSCache ¶
func LoadDNSCache(qname string) *DNSRecords
func (*DNSRecords) BuildResponse ¶
func (records *DNSRecords) BuildResponse(request []byte, qtype int, minttl uint32) []byte
func (*DNSRecords) GetAnswers ¶
func (records *DNSRecords) GetAnswers(response []byte, options ServerOptions)
func (*DNSRecords) PackAnswers ¶
func (records *DNSRecords) PackAnswers(qtype int, minttl uint32) (int, []byte)
type IPv4Range ¶
type IPv4Range struct { Start uint32 End uint32 Interface *PhantomInterface }
type IPv6Range ¶
type IPv6Range struct { Start uint64 End uint64 Interface *PhantomInterface }
type InterfaceConfig ¶
type InterfaceConfig struct { Name string `json:"name,omitempty"` Device string `json:"device,omitempty"` DNS string `json:"dns,omitempty"` Hint string `json:"hint,omitempty"` MTU int `json:"mtu,omitempty"` TTL int `json:"ttl,omitempty"` MaxTTL int `json:"maxttl,omitempty"` Protocol string `json:"protocol,omitempty"` Address string `json:"address,omitempty"` PublicKey string `json:"publickey,omitempty"` PrivateKey string `json:"privatekey,omitempty"` Peers []Peer `json:"peers,omitempty"` Timeout int `json:"timeout,omitempty"` Fallback string `json:"fallback,omitempty"` }
func (*InterfaceConfig) StartClient ¶
func (config *InterfaceConfig) StartClient() error
type PhantomInterface ¶
type PhantomInterface struct { Device string DNS string Hint uint32 MTU uint16 TTL byte MaxTTL byte Protocol byte Address string Authorization string Timeout uint16 Fallback *PhantomInterface }
var DefaultInterface *PhantomInterface = nil
func GetDNSLie ¶
func GetDNSLie(index int) (string, *PhantomInterface)
func (*PhantomInterface) Dial ¶
func (pface *PhantomInterface) Dial(conn net.Conn, host string, port int, b []byte) (net.Conn, *ConnectionInfo, error)
func (*PhantomInterface) DialUDPProxy ¶
func (*PhantomInterface) GetRemoteAddresses ¶
func (*PhantomInterface) Keep ¶
func (server *PhantomInterface) Keep(client, conn net.Conn, connInfo *ConnectionInfo)
func (*PhantomInterface) NSLookup ¶
func (pface *PhantomInterface) NSLookup(name string) (uint32, []net.IP)
func (*PhantomInterface) ProxyHandshake ¶
func (pface *PhantomInterface) ProxyHandshake(conn net.Conn, synpacket *ConnectionInfo, host string, port int, header []byte) (net.Conn, error)
func (*PhantomInterface) ResolveTCPAddr ¶
func (*PhantomInterface) ResolveTCPAddrs ¶
type PhantomProfile ¶
type PhantomProfile struct { DomainMap map[string]*PhantomInterface IPv4Ranges []IPv4Range IPv6Ranges []IPv6Range }
var DefaultProfile *PhantomProfile = nil
func (*PhantomProfile) GetInterface ¶
func (profile *PhantomProfile) GetInterface(name string) (*PhantomInterface, int)
func (*PhantomProfile) GetInterfaceByIP ¶
func (profile *PhantomProfile) GetInterfaceByIP(ip net.IP) *PhantomInterface
type RecordAddresses ¶
type ServerOptions ¶
type ServerOptions struct { ECS string Type string PD string Domain string Output string BadSubnet *net.IPNet Fallback net.IP }
func ParseOptions ¶
func ParseOptions(options string) ServerOptions
type ServiceConfig ¶
type ServiceConfig struct { Name string `json:"name,omitempty"` Device string `json:"device,omitempty"` MTU int `json:"mtu,omitempty"` Protocol string `json:"protocol,omitempty"` Method string `json:"method,omitempty"` Address string `json:"address,omitempty"` PrivateKey string `json:"privatekey,omitempty"` Profile string `json:"profile,omitempty"` Peers []Peer `json:"peers,omitempty"` }
func (*ServiceConfig) StartService ¶
func (config *ServiceConfig) StartService()
Click to show internal directories.
Click to hide internal directories.