Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type ClientConfig
- type NoisePrivateKey
- func (sk *NoisePrivateKey) Base64() (s string)
- func (sk *NoisePrivateKey) FromBase64(s string) (err error)
- func (sk *NoisePrivateKey) MarshalJSON() (result []byte, err error)
- func (sk *NoisePrivateKey) PublicKey() (pk NoisePublicKey)
- func (sk *NoisePrivateKey) ReadFromFile(path string) (err error)
- func (sk *NoisePrivateKey) SharedSecret(pk device.NoisePublicKey) (ss [blake2s.Size]byte)
- func (sk *NoisePrivateKey) UnmarshalJSON(bytes []byte) (err error)
- type NoisePublicKey
- type Packet
- func (p *Packet) FixMACs(cg *device.CookieGenerator)
- func (p *Packet) MessageType() int
- func (p *Packet) ReceiverIndex() (index uint32, err error)
- func (p *Packet) Reset()
- func (p *Packet) SetReceiverIndex(index uint32) (err error)
- func (p *Packet) SetSenderIndex(index uint32) (err error)
- func (p *Packet) Slice() []byte
- type Peer
- type Server
- type ServerConfig
- type ServerConfigPeer
- type ServerConfigServer
- type UDPAddrResolver
- type UDPAddrResolverCreator
- type WGITCacheConfig
- type WGITCacheJar
- type WGITCachePeer
- type WGITCacheTable
- type WireGuardIndexTranslationTable
- type WireGuardObfuscator
- func (o *WireGuardObfuscator) Deobfuscate(packet *Packet)
- func (o *WireGuardObfuscator) Initialize(userKey string)
- func (o *WireGuardObfuscator) Obfuscate(packet *Packet)
- func (o *WireGuardObfuscator) ReadFromUDPWithDeobfuscate(conn *net.UDPConn, packet *Packet) (err error)
- func (o *WireGuardObfuscator) WriteToUDPWithObfuscate(conn *net.UDPConn, packet *Packet) (err error)
Constants ¶
View Source
const ( PacketFlagDeobfuscatedAfterReceived = 1 << iota PacketFlagObfuscateBeforeSend )
View Source
const ( SourceValidateLevelDefault = iota // SourceValidateLevelNone (1): // do not validate the source address. // this allows client roaming but also comes with the risk of a kind of DoS attack. // this is the default behavior for ClientSourceValidateLevel. SourceValidateLevelNone // SourceValidateLevelIP (2): // validate the source address only by IP. // disable client roaming across different hosts, // maybe compatible with some kinds of NAT. SourceValidateLevelIP // SourceValidateLevelIPAndPort (3): // validate the source address by IP and port. // disabled the client roaming to defeat DoS attack, // but client need to wait timeout and resend the MessageInitiation // if they really got their IP address changed. // this is the default behavior for ServerSourceValidateLevel. SourceValidateLevelIPAndPort )
Variables ¶
View Source
var (
DebugAlwaysGenerateProxyIndex = false
)
View Source
var UDPAddrResolverCreators = map[string]UDPAddrResolverCreator{} // Type => Creator
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithConfig ¶
func NewClientWithConfig(config *ClientConfig) (outClient *Client, err error)
type ClientConfig ¶
type ClientConfig struct { Server string `json:"server"` Listen string `json:"listen"` Timeout int `json:"timeout,omitempty"` Resolver string `json:"resolver,omitempty"` ClientSourceValidateLevel int `json:"csvl,omitempty"` ServerSourceValidateLevel int `json:"ssvl,omitempty"` MaxPacketSize int `json:"max_packet_size,omitempty"` ClientPublicKey NoisePublicKey `json:"client_pubkey"` ServerPublicKey NoisePublicKey `json:"server_pubkey"` ObfuscateKey string `json:"obfs"` WGITCacheConfig // Deprecated: use Resolver instead DNS string `json:"dns,omitempty"` }
type NoisePrivateKey ¶
type NoisePrivateKey struct {
device.NoisePrivateKey
}
func (*NoisePrivateKey) Base64 ¶
func (sk *NoisePrivateKey) Base64() (s string)
func (*NoisePrivateKey) FromBase64 ¶
func (sk *NoisePrivateKey) FromBase64(s string) (err error)
func (*NoisePrivateKey) MarshalJSON ¶
func (sk *NoisePrivateKey) MarshalJSON() (result []byte, err error)
func (*NoisePrivateKey) PublicKey ¶
func (sk *NoisePrivateKey) PublicKey() (pk NoisePublicKey)
func (*NoisePrivateKey) ReadFromFile ¶
func (sk *NoisePrivateKey) ReadFromFile(path string) (err error)
func (*NoisePrivateKey) SharedSecret ¶
func (sk *NoisePrivateKey) SharedSecret(pk device.NoisePublicKey) (ss [blake2s.Size]byte)
func (*NoisePrivateKey) UnmarshalJSON ¶
func (sk *NoisePrivateKey) UnmarshalJSON(bytes []byte) (err error)
type NoisePublicKey ¶
type NoisePublicKey struct {
device.NoisePublicKey
}
func (*NoisePublicKey) Base64 ¶
func (pk *NoisePublicKey) Base64() (s string)
func (*NoisePublicKey) FromBase64 ¶
func (pk *NoisePublicKey) FromBase64(s string) (err error)
func (*NoisePublicKey) MarshalJSON ¶
func (pk *NoisePublicKey) MarshalJSON() (result []byte, err error)
func (*NoisePublicKey) UnmarshalJSON ¶
func (pk *NoisePublicKey) UnmarshalJSON(bytes []byte) (err error)
type Packet ¶
type Packet struct { Data []byte Length int Source *net.UDPAddr Destination *net.UDPAddr Flags uint64 }
func (*Packet) FixMACs ¶
func (p *Packet) FixMACs(cg *device.CookieGenerator)
func (*Packet) MessageType ¶
func (*Packet) ReceiverIndex ¶
func (*Packet) SetReceiverIndex ¶
func (*Packet) SetSenderIndex ¶
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) IsServerReplied ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServerWithConfig ¶
func NewServerWithConfig(config *ServerConfig) (outServer *Server, err error)
type ServerConfig ¶
type ServerConfig struct { Listen string `json:"listen"` Timeout int `json:"timeout,omitempty"` MaxPacketSize int `json:"max_packet_size,omitempty"` Servers []*ServerConfigServer `json:"servers"` ObfuscateKey string `json:"obfs"` WGITCacheConfig }
type ServerConfigPeer ¶
type ServerConfigPeer struct { ForwardTo string `json:"forward_to"` // ClientSourceValidateLevel is same config with the one in ServerConfigServer // but intended to be used as a per-peer override. ClientSourceValidateLevel int `json:"csvl,omitempty"` // ServerSourceValidateLevel is same config with the one in ServerConfigServer // but intended to be used as a per-peer override. ServerSourceValidateLevel int `json:"ssvl,omitempty"` ClientPublicKey *NoisePublicKey `json:"pubkey,omitempty"` // contains filtered or unexported fields }
type ServerConfigServer ¶
type ServerConfigServer struct { PrivateKey *NoisePrivateKey `json:"privkey"` PrivateKeyFile string `json:"privkey_file,omitempty"` Address string `json:"address"` Peers []*ServerConfigPeer `json:"peers"` // ClientSourceValidateLevel specified the way to handle a MessageTransport // packet that comes from a source address not matches to prior packets. ClientSourceValidateLevel int `json:"csvl,omitempty"` // ServerSourceValidateLevel specified the way to handle a MessageTransport // packet that comes from a source address not matches to prior packets. ServerSourceValidateLevel int `json:"ssvl,omitempty"` }
func (*ServerConfigServer) Initialize ¶
func (s *ServerConfigServer) Initialize() (err error)
type UDPAddrResolver ¶
type UDPAddrResolverCreator ¶
type UDPAddrResolverCreator = func(url string) (resolver UDPAddrResolver, err error)
type WGITCacheConfig ¶
type WGITCacheJar ¶
type WGITCacheJar struct {
WGITCacheConfig
}
func (*WGITCacheJar) LoadLocked ¶
func (*WGITCacheJar) SaveLocked ¶
func (c *WGITCacheJar) SaveLocked(clientMap map[uint32]*Peer) (err error)
type WGITCachePeer ¶
type WGITCachePeer struct { ClientOriginIndex uint32 `json:"coidx"` ClientProxyIndex uint32 `json:"cpidx"` ClientPublicKey NoisePublicKey `json:"cpk"` ClientDestination string `json:"cdst"` ClientSourceValidateLevel int `json:"csvl"` ServerOriginIndex uint32 `json:"soidx"` ServerProxyIndex uint32 `json:"spidx"` ServerPublicKey NoisePublicKey `json:"spk"` ServerDestination string `json:"sdst"` ServerSourceValidateLevel int `json:"ssvl"` ObfuscateEnabled bool `json:"obfe"` }
func (*WGITCachePeer) FromWGITPeer ¶
func (cp *WGITCachePeer) FromWGITPeer(peer *Peer) (err error)
func (*WGITCachePeer) WGITPeer ¶
func (cp *WGITCachePeer) WGITPeer() (peer *Peer, err error)
type WGITCacheTable ¶
type WGITCacheTable struct {
ClientMap []WGITCachePeer `json:"client_map"`
}
type WireGuardIndexTranslationTable ¶
type WireGuardIndexTranslationTable struct { ClientListen *net.UDPAddr ClientReadFromUDPFunc func(conn *net.UDPConn, packet *Packet) (err error) ClientWriteToUDPFunc func(conn *net.UDPConn, packet *Packet) (err error) ServerListen *net.UDPAddr ServerReadFromUDPFunc func(conn *net.UDPConn, packet *Packet) (err error) ServerWriteToUDPFunc func(conn *net.UDPConn, packet *Packet) (err error) Timeout time.Duration ExtractPeerFunc func(msg *device.MessageInitiation) (fi *ServerConfigPeer, err error) CacheJar WGITCacheJar // UpdateAllServerDestinationChan is used to set all server address for mwgp-client (in case of DNS update). // this channel is not intended to be used by mwgp-server. UpdateAllServerDestinationChan chan *net.UDPAddr // MaxPacketSize is the maximum size of a WireGuard packet. // // We use the default value of 65536, which is the maximum possible size of a UDP packet. // // However, in most cases, 1500 is sufficient because WireGuard will only send // large UDP packets when you configure a large MTU on the WireGuard interface. // // If you are running mwgp on a server with limited memory, you can adjust this to // reduce memory consumption. MaxPacketSize uint // contains filtered or unexported fields }
func NewWireGuardIndexTranslationTable ¶
func NewWireGuardIndexTranslationTable() (table *WireGuardIndexTranslationTable)
func (*WireGuardIndexTranslationTable) Serve ¶
func (t *WireGuardIndexTranslationTable) Serve() (err error)
type WireGuardObfuscator ¶
type WireGuardObfuscator struct { ReadFromUDPFunc func(conn *net.UDPConn, packet *Packet) (err error) WriteToUDPFunc func(conn *net.UDPConn, packet *Packet) (err error) // contains filtered or unexported fields }
func (*WireGuardObfuscator) Deobfuscate ¶
func (o *WireGuardObfuscator) Deobfuscate(packet *Packet)
func (*WireGuardObfuscator) Initialize ¶
func (o *WireGuardObfuscator) Initialize(userKey string)
func (*WireGuardObfuscator) Obfuscate ¶
func (o *WireGuardObfuscator) Obfuscate(packet *Packet)
func (*WireGuardObfuscator) ReadFromUDPWithDeobfuscate ¶
func (o *WireGuardObfuscator) ReadFromUDPWithDeobfuscate(conn *net.UDPConn, packet *Packet) (err error)
func (*WireGuardObfuscator) WriteToUDPWithObfuscate ¶
func (o *WireGuardObfuscator) WriteToUDPWithObfuscate(conn *net.UDPConn, packet *Packet) (err error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.