mirror of
				https://github.com/therootcompany/sclient
				synced 2024-11-16 17:09:00 +00:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					bc4aeb3124 | ||
| 
						 | 
					8783d46849 | ||
| 
						 | 
					b27b32700c | ||
| aac3959dc7 | |||
| acaa3d3537 | 
@ -3,25 +3,34 @@ before:
 | 
				
			|||||||
    - go mod download
 | 
					    - go mod download
 | 
				
			||||||
    - go generate ./...
 | 
					    - go generate ./...
 | 
				
			||||||
builds:
 | 
					builds:
 | 
				
			||||||
  - main: ./cmd/sclient/main.go
 | 
					  - main: ./cmd/sclient/
 | 
				
			||||||
    env:
 | 
					    env:
 | 
				
			||||||
      - CGO_ENABLED=0
 | 
					      - CGO_ENABLED=0
 | 
				
			||||||
    goos:
 | 
					    goos:
 | 
				
			||||||
      - linux
 | 
					 | 
				
			||||||
      - windows
 | 
					 | 
				
			||||||
      - darwin
 | 
					      - darwin
 | 
				
			||||||
 | 
					      - linux
 | 
				
			||||||
 | 
					      - freebsd
 | 
				
			||||||
 | 
					      - windows
 | 
				
			||||||
 | 
					      - js
 | 
				
			||||||
    goarch:
 | 
					    goarch:
 | 
				
			||||||
      - 386
 | 
					 | 
				
			||||||
      - amd64
 | 
					      - amd64
 | 
				
			||||||
      - arm
 | 
					      - arm
 | 
				
			||||||
      - arm64
 | 
					      - arm64
 | 
				
			||||||
 | 
					      - wasm
 | 
				
			||||||
    goarm:
 | 
					    goarm:
 | 
				
			||||||
      - 6
 | 
					 | 
				
			||||||
      - 7
 | 
					      - 7
 | 
				
			||||||
 | 
					    goamd64:
 | 
				
			||||||
 | 
					      - v2
 | 
				
			||||||
 | 
					    ignore:
 | 
				
			||||||
 | 
					      - goos: windows
 | 
				
			||||||
 | 
					        goarch: 386
 | 
				
			||||||
 | 
					      - goos: windows
 | 
				
			||||||
 | 
					        goarm: 6
 | 
				
			||||||
 | 
					      - goos: windows
 | 
				
			||||||
 | 
					        goarm: 7
 | 
				
			||||||
archives:
 | 
					archives:
 | 
				
			||||||
  - replacements:
 | 
					  - id: sclient-binary
 | 
				
			||||||
      386: i386
 | 
					    format: tar.xz
 | 
				
			||||||
      amd64: x86_64
 | 
					 | 
				
			||||||
    format_overrides:
 | 
					    format_overrides:
 | 
				
			||||||
      - goos: windows
 | 
					      - goos: windows
 | 
				
			||||||
        format: zip
 | 
					        format: zip
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								.prettierrc.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.prettierrc.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "printWidth": 80,
 | 
				
			||||||
 | 
					  "tabWidth": 2,
 | 
				
			||||||
 | 
					  "singleQuote": false,
 | 
				
			||||||
 | 
					  "bracketSpacing": true,
 | 
				
			||||||
 | 
					  "proseWrap": "always",
 | 
				
			||||||
 | 
					  "semi": true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										38
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								README.md
									
									
									
									
									
								
							@ -1,6 +1,7 @@
 | 
				
			|||||||
# sclient
 | 
					# sclient
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Secure Client for exposing TLS (aka SSL) secured services as plain-text connections locally.
 | 
					Secure Client for exposing TLS (aka SSL) secured services as plain-text
 | 
				
			||||||
 | 
					connections locally.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Also ideal for multiplexing a single port with multiple protocols using SNI.
 | 
					Also ideal for multiplexing a single port with multiple protocols using SNI.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -30,7 +31,8 @@ cURL
 | 
				
			|||||||
curl http://localhost:3000 -H 'Host: whatever.com'
 | 
					curl http://localhost:3000 -H 'Host: whatever.com'
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A poor man's (or Windows user's) makeshift replacement for `openssl s_client`, `stunnel`, or `socat`.
 | 
					A poor man's (or Windows user's) makeshift replacement for `openssl s_client`,
 | 
				
			||||||
 | 
					`stunnel`, or `socat`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Table of Contents
 | 
					# Table of Contents
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -53,9 +55,11 @@ curl.exe -A MS https://webinstall.dev/sclient | powershell
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### Downloads
 | 
					### Downloads
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Check the [Github Releases](https://github.com/therootcompany/sclient/releases) for
 | 
					Check the [Github Releases](https://github.com/therootcompany/sclient/releases)
 | 
				
			||||||
 | 
					for
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- macOS (x64) Apple Silicon [coming soon](https://github.com/golang/go/issues/39782)
 | 
					- macOS (x64) Apple Silicon
 | 
				
			||||||
 | 
					  [coming soon](https://github.com/golang/go/issues/39782)
 | 
				
			||||||
- Linux (x64, i386, arm64, arm6, arm7)
 | 
					- Linux (x64, i386, arm64, arm6, arm7)
 | 
				
			||||||
- Windows 10 (x64, i386)
 | 
					- Windows 10 (x64, i386)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -66,8 +70,11 @@ sclient [flags] <remote> <local>
 | 
				
			|||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- flags
 | 
					- flags
 | 
				
			||||||
  - -k, --insecure ignore invalid TLS (SSL/HTTPS) certificates
 | 
					  - `-s`, `--silent` less verbose logging
 | 
				
			||||||
  - --servername <string> spoof SNI (to disable use IP as <remote> and do not use this option)
 | 
					  - `-k`, `--insecure` ignore invalid TLS (SSL/HTTPS) certificates
 | 
				
			||||||
 | 
					  - `--servername <domain>` spoof SNI (to disable use IP as <remote> and do
 | 
				
			||||||
 | 
					    not use this option)
 | 
				
			||||||
 | 
					  - `--alpn <protocol-list>`
 | 
				
			||||||
- remote
 | 
					- remote
 | 
				
			||||||
  - must have servername (i.e. example.com)
 | 
					  - must have servername (i.e. example.com)
 | 
				
			||||||
  - port is optional (default is 443)
 | 
					  - port is optional (default is 443)
 | 
				
			||||||
@ -75,6 +82,17 @@ sclient [flags] <remote> <local>
 | 
				
			|||||||
  - address is optional (default is localhost)
 | 
					  - address is optional (default is localhost)
 | 
				
			||||||
  - must have port (i.e. 3000)
 | 
					  - must have port (i.e. 3000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -alpn string
 | 
				
			||||||
 | 
					    	acceptable protocols, ex: 'h2,http/1.1' 'http/1.1' (default) 'ssh' (default "http/1.1")
 | 
				
			||||||
 | 
					  -insecure
 | 
				
			||||||
 | 
					    	ignore bad TLS/SSL/HTTPS certificates
 | 
				
			||||||
 | 
					  -k	alias for --insecure
 | 
				
			||||||
 | 
					  -s	alias of --silent
 | 
				
			||||||
 | 
					  -servername string
 | 
				
			||||||
 | 
					    	specify a servername different from <remote> (to disable SNI use an IP as <remote> and do use this option)
 | 
				
			||||||
 | 
					  -silent
 | 
				
			||||||
 | 
					    	less verbose output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Examples
 | 
					# Examples
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Bridge between `telebit.cloud` and local port `3000`.
 | 
					Bridge between `telebit.cloud` and local port `3000`.
 | 
				
			||||||
@ -121,10 +139,14 @@ sclient --servername "Robert'); DROP TABLE Students;" -k example.com localhost:3
 | 
				
			|||||||
sclient --servername "../../../.hidden/private.txt" -k example.com localhost:3000
 | 
					sclient --servername "../../../.hidden/private.txt" -k example.com localhost:3000
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					See [Go Docs](https://pkg.go.dev/github.com/therootcompany/sclient).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Build from source
 | 
					# Build from source
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You'll need to install [Go](https://golang.org).
 | 
					You'll need to install [Go](https://golang.org). See
 | 
				
			||||||
See [webinstall.dev/golang](https://webinstall.dev/golang) for install instructions.
 | 
					[webinstall.dev/golang](https://webinstall.dev/golang) for install instructions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
curl -sS https://webinstall.dev/golang | bash
 | 
					curl -sS https://webinstall.dev/golang | bash
 | 
				
			||||||
 | 
				
			|||||||
@ -40,20 +40,30 @@ func usage() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
	if len(os.Args) >= 2 {
 | 
						if len(os.Args) >= 2 {
 | 
				
			||||||
		if "version" == strings.TrimLeft(os.Args[1], "-") {
 | 
							if os.Args[1] == "-V" || strings.TrimLeft(os.Args[1], "-") == "version" {
 | 
				
			||||||
			fmt.Printf("%s\n", ver())
 | 
								fmt.Printf("%s\n", ver())
 | 
				
			||||||
			os.Exit(0)
 | 
								os.Exit(0)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var alpnList string
 | 
				
			||||||
 | 
						var insecure bool
 | 
				
			||||||
 | 
						var servername string
 | 
				
			||||||
 | 
						var silent bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.Usage = usage
 | 
						flag.Usage = usage
 | 
				
			||||||
	insecure := flag.Bool("k", false, "alias for --insecure")
 | 
					
 | 
				
			||||||
	silent := flag.Bool("s", false, "alias of --silent")
 | 
						flag.StringVar(&alpnList, "alpn", "", "acceptable protocols, ex: 'h2,http/1.1' 'http/1.1' 'ssh'")
 | 
				
			||||||
	servername := flag.String("servername", "", "specify a servername different from <remote> (to disable SNI use an IP as <remote> and do use this option)")
 | 
						flag.BoolVar(&insecure, "k", false, "alias for --insecure")
 | 
				
			||||||
	flag.BoolVar(insecure, "insecure", false, "ignore bad TLS/SSL/HTTPS certificates")
 | 
						flag.BoolVar(&silent, "s", false, "alias of --silent")
 | 
				
			||||||
	flag.BoolVar(silent, "silent", false, "less verbose output")
 | 
						flag.StringVar(&servername, "servername", "", "specify a servername different from <remote> (to disable SNI use an IP as <remote> and do not use this option)")
 | 
				
			||||||
 | 
						flag.BoolVar(&insecure, "insecure", false, "ignore bad TLS/SSL/HTTPS certificates")
 | 
				
			||||||
 | 
						flag.BoolVar(&silent, "silent", false, "less verbose output")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						alpns := parseOptionList(alpnList)
 | 
				
			||||||
	remotestr := flag.Arg(0)
 | 
						remotestr := flag.Arg(0)
 | 
				
			||||||
	localstr := flag.Arg(1)
 | 
						localstr := flag.Arg(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,9 +81,10 @@ func main() {
 | 
				
			|||||||
	sclient := &sclient.Tunnel{
 | 
						sclient := &sclient.Tunnel{
 | 
				
			||||||
		RemotePort:         443,
 | 
							RemotePort:         443,
 | 
				
			||||||
		LocalAddress:       "localhost",
 | 
							LocalAddress:       "localhost",
 | 
				
			||||||
		InsecureSkipVerify: *insecure,
 | 
							InsecureSkipVerify: insecure,
 | 
				
			||||||
		ServerName:         *servername,
 | 
							ServerName:         servername,
 | 
				
			||||||
		Silent:             *silent,
 | 
							Silent:             silent,
 | 
				
			||||||
 | 
							NextProtos:         alpns,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	remote := strings.Split(remotestr, ":")
 | 
						remote := strings.Split(remotestr, ":")
 | 
				
			||||||
@ -124,3 +135,18 @@ func main() {
 | 
				
			|||||||
		//os.Exit(6)
 | 
							//os.Exit(6)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// parsers "a,b,c" "a b c" and "a, b, c" all the same
 | 
				
			||||||
 | 
					func parseOptionList(optionList string) []string {
 | 
				
			||||||
 | 
						optionList = strings.TrimSpace(optionList)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if len(optionList) == 0 {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						options := []string{}
 | 
				
			||||||
 | 
						optionList = strings.ReplaceAll(optionList, ",", " ")
 | 
				
			||||||
 | 
						options = strings.Fields(optionList)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return options
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -17,6 +17,7 @@ type Tunnel struct {
 | 
				
			|||||||
	LocalAddress       string
 | 
						LocalAddress       string
 | 
				
			||||||
	LocalPort          int
 | 
						LocalPort          int
 | 
				
			||||||
	InsecureSkipVerify bool
 | 
						InsecureSkipVerify bool
 | 
				
			||||||
 | 
						NextProtos         []string
 | 
				
			||||||
	ServerName         string
 | 
						ServerName         string
 | 
				
			||||||
	Silent             bool
 | 
						Silent             bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -29,6 +30,7 @@ func (t *Tunnel) DialAndListen() error {
 | 
				
			|||||||
		&tls.Config{
 | 
							&tls.Config{
 | 
				
			||||||
			ServerName:         t.ServerName,
 | 
								ServerName:         t.ServerName,
 | 
				
			||||||
			InsecureSkipVerify: t.InsecureSkipVerify,
 | 
								InsecureSkipVerify: t.InsecureSkipVerify,
 | 
				
			||||||
 | 
								NextProtos:         t.NextProtos,
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user