2 GoVPN -- simple secure free software virtual private network daemon
3 Copyright (C) 2014-2019 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 "cypherpunks.ru/govpn"
30 func (c *Client) proxyTCP() {
31 proxyAddr, err := net.ResolveTCPAddr("tcp", c.config.ProxyAddress)
36 conn, err := net.DialTCP("tcp", nil, proxyAddr)
41 req := "CONNECT " + c.config.ProxyAddress + " HTTP/1.1\n"
42 req += "Host: " + c.config.ProxyAddress + "\n"
43 if c.config.ProxyAuthentication != "" {
44 req += "Proxy-Authorization: Basic "
45 req += base64.StdEncoding.EncodeToString([]byte(c.config.ProxyAuthentication)) + "\n"
48 conn.Write([]byte(req))
49 resp, err := http.ReadResponse(
50 bufio.NewReader(conn),
51 &http.Request{Method: "CONNECT"},
53 if err != nil || resp.StatusCode != http.StatusOK {
54 c.Error <- fmt.Errorf("Unexpected response from proxy: %s", err.Error())
57 govpn.Printf(`[proxy-connected remote="%s" addr="%s"]`, c.config.RemoteAddress, (*proxyAddr).String())