Skip to content

Commit 3732e61

Browse files
Merge pull request #1 from alfonso-presa/feature/as-library
Feature/as library
2 parents f3a8df2 + cfcd172 commit 3732e61

File tree

8 files changed

+47
-14
lines changed

8 files changed

+47
-14
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ $ chisel client --help
216216
the chisel server. Authentication can be specified inside the URL.
217217
For example, http://admin:[email protected]:8081
218218
219+
--skip-tls-verification, Don't verify the server's TLS certificate
220+
chain and host name (if TLS is used for transport connections to
221+
server). If set, client accepts any TLS certificate presented by
222+
the server and any host name in that certificate. This influences
223+
only transport https (wss) connections. Chisel server's public key
224+
may be still verified (see --fingerprint) after inner connection
225+
is established.
226+
219227
--hostname, Optionally set the 'Host' header (defaults to the host
220228
defined in the endpoint url).
221229

client/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package chclient
22

33
import (
44
"context"
5+
"crypto/tls"
56
"fmt"
67
"io"
78
"net"
@@ -13,7 +14,7 @@ import (
1314

1415
"github.com/gorilla/websocket"
1516
"github.com/jpillora/backoff"
16-
"github.com/jpillora/chisel/share"
17+
"github.com/alfonso-presa/chisel/share"
1718
"golang.org/x/crypto/ssh"
1819
)
1920

@@ -26,6 +27,7 @@ type Config struct {
2627
MaxRetryCount int
2728
MaxRetryInterval time.Duration
2829
Server string
30+
SkipTlsVerification bool
2931
HTTPProxy string
3032
Remotes []string
3133
HostHeader string
@@ -199,6 +201,9 @@ func (c *Client) connectionLoop() {
199201
return c.httpProxyURL, nil
200202
}
201203
}
204+
if c.config.SkipTlsVerification {
205+
d.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
206+
}
202207
wsHeaders := http.Header{}
203208
if c.config.HostHeader != "" {
204209
wsHeaders = http.Header{

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
module github.com/jpillora/chisel
1+
module github.com/alfonso-presa/chisel
22

33
require (
4-
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 // indirect
54
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
65
github.com/fsnotify/fsnotify v1.4.7
76
github.com/gorilla/websocket v1.4.0
8-
github.com/jpillora/ansi v0.0.0-20170202005112-f496b27cd669 // indirect
97
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7
8+
github.com/jpillora/chisel v0.0.0-20190724232113-f3a8df20e389
109
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82
1110
github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9
12-
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect
13-
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e
14-
golang.org/x/net v0.0.0-20181017193950-04a2e542c03f // indirect
15-
golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8 // indirect
11+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
12+
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 // indirect
13+
golang.org/x/sys v0.0.0-20190927073244-c990c680b611 // indirect
1614
)
15+
16+
go 1.13

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ github.com/jpillora/ansi v0.0.0-20170202005112-f496b27cd669 h1:l5rH/CnVVu+HPxjtx
1010
github.com/jpillora/ansi v0.0.0-20170202005112-f496b27cd669/go.mod h1:kOeLNvjNBGSV3uYtFjvb72+fnZCMFJF1XDvRIjdom0g=
1111
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 h1:K//n/AqR5HjG3qxbrBCL4vJPW0MVFSs9CPK1OOJdRME=
1212
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
13+
github.com/jpillora/chisel v0.0.0-20190724232113-f3a8df20e389 h1:K3JsoRqX6C4gmTvY4jqtFGCfK8uToj9DMahciJaoWwE=
14+
github.com/jpillora/chisel v0.0.0-20190724232113-f3a8df20e389/go.mod h1:wHQUFFnFySoqdAOzjHkTvb4DsVM1h/73PS9l2vnioRM=
1315
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82 h1:7ufdyC3aMxFcCv+ABZy/dmIVGKFoGNBCqOgLYPIckD8=
1416
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82/go.mod h1:w8buj+yNfmLEP0ENlbG/FRnK6bVmuhqXnukYCs9sDvY=
1517
github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9 h1:0c9jcgBtHRtDU//jTrcCgWG6UHjMZytiq/3WhraNgUM=
@@ -18,7 +20,15 @@ github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9
1820
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
1921
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e h1:IzypfodbhbnViNUO/MEh0FzCUooG97cIGfdggUrUSyU=
2022
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
23+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
24+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2125
golang.org/x/net v0.0.0-20181017193950-04a2e542c03f h1:4pRM7zYwpBjCnfA1jRmhItLxYJkaEnsmuAcRtA347DA=
2226
golang.org/x/net v0.0.0-20181017193950-04a2e542c03f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
27+
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD1IoslhYu7AmdsVzCcs=
28+
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
2329
golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8 h1:R91KX5nmbbvEd7w370cbVzKC+EzCTGqZq63Zad5IcLM=
2430
golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
31+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
32+
golang.org/x/sys v0.0.0-20190927073244-c990c680b611 h1:q9u40nxWT5zRClI/uU9dHCiYGottAg6Nzz4YUQyHxdA=
33+
golang.org/x/sys v0.0.0-20190927073244-c990c680b611/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
34+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"os"
99
"strconv"
1010

11-
"github.com/jpillora/chisel/client"
12-
"github.com/jpillora/chisel/server"
13-
chshare "github.com/jpillora/chisel/share"
11+
"github.com/alfonso-presa/chisel/client"
12+
"github.com/alfonso-presa/chisel/server"
13+
chshare "github.com/alfonso-presa/chisel/share"
1414
)
1515

1616
var help = `
@@ -264,6 +264,14 @@ var clientHelp = `
264264
the chisel server. Authentication can be specified inside the URL.
265265
For example, http://admin:[email protected]:8081
266266
267+
--skip-tls-verification, Don't verify the server's TLS certificate
268+
chain and host name (if TLS is used for transport connections to
269+
server). If set, client accepts any TLS certificate presented by
270+
the server and any host name in that certificate. This influences
271+
only transport https (wss) connections. Chisel server's public key
272+
may be still verified (see --fingerprint) after inner connection
273+
is established.
274+
267275
--hostname, Optionally set the 'Host' header (defaults to the host
268276
found in the server url).
269277
` + commonHelp
@@ -278,6 +286,7 @@ func client(args []string) {
278286
maxRetryCount := flags.Int("max-retry-count", -1, "")
279287
maxRetryInterval := flags.Duration("max-retry-interval", 0, "")
280288
proxy := flags.String("proxy", "", "")
289+
skipTlsVerification := flags.Bool("skip-tls-verification", false, "")
281290
pid := flags.Bool("pid", false, "")
282291
hostname := flags.String("hostname", "", "")
283292
verbose := flags.Bool("v", false, "")
@@ -302,6 +311,7 @@ func client(args []string) {
302311
MaxRetryInterval: *maxRetryInterval,
303312
HTTPProxy: *proxy,
304313
Server: args[0],
314+
SkipTlsVerification: *skipTlsVerification,
305315
Remotes: args[1:],
306316
HostHeader: *hostname,
307317
})

server/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"golang.org/x/crypto/ssh"
1212

13-
"github.com/jpillora/chisel/share"
13+
"github.com/alfonso-presa/chisel/share"
1414
)
1515

1616
// handleClientHandler is the main http websocket handler for the chisel server

server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/jpillora/requestlog"
1616
"golang.org/x/crypto/ssh"
1717

18-
"github.com/jpillora/chisel/share"
18+
"github.com/alfonso-presa/chisel/share"
1919
)
2020

2121
// Config is the configuration for the chisel service

test/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"path"
2626
"strconv"
2727

28-
"github.com/jpillora/chisel/share"
28+
chshare "github.com/alfonso-presa/chisel/share"
2929

3030
"time"
3131
)

0 commit comments

Comments
 (0)