NewClient creates a new Client instance with the provided parameters.
(config ClientConfig)
| 71 | |
| 72 | // NewClient creates a new Client instance with the provided parameters. |
| 73 | func NewClient(config ClientConfig) *Client { |
| 74 | l := make(map[string]bool) |
| 75 | for _, s := range config.LowLatencyAddrs { |
| 76 | l[s] = true |
| 77 | } |
| 78 | |
| 79 | redactedConfig := config |
| 80 | redactedConfig.AuthToken = "REDACTED" |
| 81 | |
| 82 | c := &Client{ |
| 83 | proxyAddr: config.ProxyAddr, |
| 84 | authToken: config.AuthToken, |
| 85 | h2Transport: nil, |
| 86 | h2Conns: []*gohttp2.ClientConn{}, |
| 87 | tlsConn: nil, |
| 88 | tlsTimeout: masque.MaxTLSDialTimeout, |
| 89 | tcpReqs: map[uint64]*Conn{}, |
| 90 | udpReqs: map[uint64]*Conn{}, |
| 91 | certData: config.CertData, |
| 92 | prot: config.Prot, |
| 93 | lowLatencyAddrs: l, |
| 94 | logger: config.Logger.With("config", redactedConfig), |
| 95 | ignoreCert: config.IgnoreCert, |
| 96 | } |
| 97 | return c |
| 98 | } |
| 99 | |
| 100 | // ConnectToProxy connects the Client to the proxy. |
| 101 | func (c *Client) ConnectToProxy() error { |
no outgoing calls