Documentation ¶
Index ¶
- Constants
- Variables
- func AddConn(synAddr string, option 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 DialUDP(address string) (net.Conn, error)
- func GetAddressFromInterface(iface string, ipv6 bool) (string, error)
- 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) string
- func GetQName(buf []byte) (string, int, int)
- func GetQUICSNI(b []byte) string
- func GetQUICVersion(data []byte) uint32
- func GetSNI(b []byte) (offset int, length int)
- 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 LoadConfig(filename string) error
- func LoadHosts(filename string) error
- func ModifyAndSendPacket(connInfo *ConnectionInfo, payload []byte, hint uint32, ttl uint8, count int) error
- func NSLookup(name string, hint uint32, server string) (int, []net.IP)
- func NSRequest(request []byte, cache bool) (int, []byte)
- 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, record *DNSRecords)
- func TCPMapping(Address string, 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 TLSlookup(request []byte, address string) ([]byte, error)
- func TProxyUDP(address string)
- func UDPMapping(Address, Host string) error
- func UDPlookup(request []byte, address string) ([]byte, error)
- type ConnectionInfo
- type DNSRecords
- type InterfaceConfig
- type Peer
- type PhantomInterface
- func (pface *PhantomInterface) Dial(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 (server *PhantomInterface) GetRemoteAddresses(host string, port int) ([]*net.TCPAddr, error)
- func (server *PhantomInterface) Keep(client, conn net.Conn, connInfo *ConnectionInfo)
- func (server *PhantomInterface) ProxyHandshake(conn net.Conn, synpacket *ConnectionInfo, host string, port int) error
- func (server *PhantomInterface) ResolveTCPAddr(host string, port int) (*net.TCPAddr, error)
- func (server *PhantomInterface) ResolveTCPAddrs(host string, port int) ([]*net.TCPAddr, error)
- type RecordAddresses
- type ServerOptions
- type ServiceConfig
- type SynInfo
- type WireGuardInterface
- type WireGuardInterfaceConfig
- type WireGuardServiceConfig
Constants ¶
View Source
const ( DIRECT = 0x0 REDIRECT = 0x1 NAT64 = 0x2 HTTP = 0x3 HTTPS = 0x4 SOCKS4 = 0x5 SOCKS5 = 0x6 WIREGUARD = 0x7 )
View Source
const ( OPT_NONE = 0x0 OPT_TTL = 0x1 << 0 OPT_MSS = 0x1 << 1 OPT_WMD5 = 0x1 << 2 OPT_NACK = 0x1 << 3 OPT_WACK = 0x1 << 4 OPT_WCSUM = 0x1 << 5 OPT_WSEQ = 0x1 << 6 OPT_WTIME = 0x1 << 7 OPT_TFO = 0x1 << 8 OPT_UDP = 0x1 << 9 OPT_NOTCP = 0x1 << 10 OPT_DELAY = 0x1 << 11 OPT_MODE2 = 0x1 << 12 OPT_DF = 0x1 << 13 OPT_SAT = 0x1 << 14 OPT_RAND = 0x1 << 15 OPT_SSEG = 0x1 << 16 OPT_1SEG = 0x1 << 17 OPT_HTFO = 0x1 << 18 OPT_KEEPALIVE = 0x1 << 19 OPT_SYNX2 = 0x1 << 20 OPT_ZERO = 0x1 << 21 OPT_HTTP = 0x1 << 23 OPT_HTTPS = 0x1 << 24 OPT_HTTP3 = 0x1 << 25 OPT_MOVE = 0x1 << 26 OPT_STRIP = 0x1 << 27 OPT_FRONTING = 0x1 << 28 OPT_IPV4 = 0x1 << 30 OPT_IPV6 = 0x1 << 31 )
View Source
const ( SO_ORIGINAL_DST = 80 IP6T_SO_ORIGINAL_DST = 80 )
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 sync.Map
View Source
var DNSMinTTL uint32 = 0
View Source
var DomainMap map[string]*PhantomInterface
View Source
var Forward bool = false
View Source
var HintMap = map[string]uint32{ "none": OPT_NONE, "ttl": OPT_TTL, "mss": OPT_MSS, "w-md5": OPT_WMD5, "n-ack": OPT_NACK, "w-ack": OPT_WACK, "w-csum": OPT_WCSUM, "w-seq": OPT_WSEQ, "w-time": OPT_WTIME, "tfo": OPT_TFO, "udp": OPT_UDP, "no-tcp": OPT_NOTCP, "delay": OPT_DELAY, "mode2": OPT_MODE2, "df": OPT_DF, "sat": OPT_SAT, "rand": OPT_RAND, "s-seg": OPT_SSEG, "1-seg": OPT_1SEG, "half-tfo": OPT_HTFO, "keep-alive": OPT_KEEPALIVE, "synx2": OPT_SYNX2, "zero": OPT_ZERO, "http": OPT_HTTP, "https": OPT_HTTPS, "h3": OPT_HTTP3, "move": OPT_MOVE, "strip": OPT_STRIP, "fronting": OPT_FRONTING, "ipv4": OPT_IPV4, "ipv6": OPT_IPV6, }
View Source
var InterfaceMap map[string]PhantomInterface
View Source
var LogLevel = 0
View Source
var Logger *log.Logger
View Source
var Nose []string = []string{"phantom.socks"}
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 ComputeUDPChecksum ¶
func ConnectionMonitor ¶
func CreateInterfaces ¶
func CreateInterfaces(Interfaces []InterfaceConfig) []string
func DNSTCPServer ¶
func DevicePrint ¶
func DevicePrint()
func GetAddressFromInterface ¶
func GetNameOffset ¶
func GetQUICSNI ¶
func GetQUICVersion ¶
func IsAddressInUse ¶
func IsNormalError ¶
func LoadConfig ¶
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, record *DNSRecords)
func TCPMapping ¶
func TCPlookup ¶
func TCPlookup(request []byte, address string, server *PhantomInterface) ([]byte, error)
func TCPlookupDNS64 ¶
func UDPMapping ¶
Types ¶
type ConnectionInfo ¶
func DialConnInfo ¶
func DialConnInfo(laddr, raddr *net.TCPAddr, server *PhantomInterface, payload []byte) (net.Conn, *ConnectionInfo, error)
type DNSRecords ¶
type DNSRecords struct { Index int Hint uint A *RecordAddresses AAAA *RecordAddresses }
func LoadDNSCache ¶
func LoadDNSCache(qname string) *DNSRecords
func (DNSRecords) BuildResponse ¶
func (records DNSRecords) BuildResponse(request []byte, qtype int, ttl uint32) []byte
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"` PrivateKey string `json:"privatekey,omitempty"` Peers []Peer `json:"peers,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 }
var DefaultInterface *PhantomInterface = nil
func ConfigLookup ¶
func ConfigLookup(name string) *PhantomInterface
func GetConfig ¶
func GetConfig(name string) *PhantomInterface
func (*PhantomInterface) Dial ¶
func (pface *PhantomInterface) Dial(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) ProxyHandshake ¶
func (server *PhantomInterface) ProxyHandshake(conn net.Conn, synpacket *ConnectionInfo, host string, port int) error
func (*PhantomInterface) ResolveTCPAddr ¶
func (*PhantomInterface) ResolveTCPAddrs ¶
type RecordAddresses ¶
type ServerOptions ¶
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"` Address string `json:"address,omitempty"` PrivateKey string `json:"privatekey,omitempty"` Peers []Peer `json:"peers,omitempty"` }
func (ServiceConfig) StartService ¶
func (config ServiceConfig) StartService()
type WireGuardInterface ¶
type WireGuardInterface struct {
PhantomInterface
}
type WireGuardInterfaceConfig ¶
type WireGuardInterfaceConfig struct {
InterfaceConfig
}
type WireGuardServiceConfig ¶
type WireGuardServiceConfig struct {
ServiceConfig
}
Click to show internal directories.
Click to hide internal directories.