use conventional command and package paths
This commit is contained in:
parent
c786b0bd07
commit
d4eb17ea44
|
@ -52,12 +52,12 @@ For the moment you'll have to install go and compile `sclient` yourself:
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.coolaj86.com/coolaj86/sclient.go.git
|
git clone https://git.coolaj86.com/coolaj86/sclient.go.git
|
||||||
pushd sclient.go
|
pushd sclient.go
|
||||||
go build -o dist/sclient sclient*.go
|
go build -o dist/sclient cmd/sclient/main.go
|
||||||
rsync -av dist/sclient /usr/local/bin/sclient
|
rsync -av dist/sclient /usr/local/bin/sclient
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go run sclient*.go example.com:443 localhost:3000
|
go run cmd/sclient/main.go example.com:443 localhost:3000
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
|
16
build-all.sh
16
build-all.sh
|
@ -1,29 +1,31 @@
|
||||||
#GOOS=windows GOARCH=amd64 go install
|
#GOOS=windows GOARCH=amd64 go install
|
||||||
go tool dist list
|
go tool dist list
|
||||||
|
|
||||||
|
gocmd=cmd/sclient/main.go
|
||||||
|
golib=""
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Windows amd64"
|
echo "Windows amd64"
|
||||||
GOOS=windows GOARCH=amd64 go build -o dist/windows/amd64/sclient.exe sclient*.go
|
GOOS=windows GOARCH=amd64 go build -o dist/windows/amd64/sclient.exe $gocmd $golib
|
||||||
echo "Windows 386"
|
echo "Windows 386"
|
||||||
GOOS=windows GOARCH=386 go build -o dist/windows/386/sclient.exe sclient*.go
|
GOOS=windows GOARCH=386 go build -o dist/windows/386/sclient.exe $gocmd $golib
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Darwin (macOS) amd64"
|
echo "Darwin (macOS) amd64"
|
||||||
GOOS=darwin GOARCH=amd64 go build -o dist/darwin/amd64/sclient sclient*.go
|
GOOS=darwin GOARCH=amd64 go build -o dist/darwin/amd64/sclient $gocmd $golib
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Linux amd64"
|
echo "Linux amd64"
|
||||||
GOOS=linux GOARCH=amd64 go build -o dist/linux/amd64/sclient sclient*.go
|
GOOS=linux GOARCH=amd64 go build -o dist/linux/amd64/sclient $gocmd $golib
|
||||||
echo "Linux 386"
|
echo "Linux 386"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
GOOS=linux GOARCH=386 go build -o dist/linux/386/sclient sclient*.go
|
GOOS=linux GOARCH=386 go build -o dist/linux/386/sclient $gocmd $golib
|
||||||
echo "RPi 3 B+ ARMv7"
|
echo "RPi 3 B+ ARMv7"
|
||||||
GOOS=linux GOARCH=arm GOARM=7 go build -o dist/linux/armv7/sclient sclient*.go
|
GOOS=linux GOARCH=arm GOARM=7 go build -o dist/linux/armv7/sclient $gocmd $golib
|
||||||
echo "RPi Zero ARMv5"
|
echo "RPi Zero ARMv5"
|
||||||
GOOS=linux GOARCH=arm GOARM=5 go build -o dist/linux/armv5/sclient sclient*.go
|
GOOS=linux GOARCH=arm GOARM=5 go build -o dist/linux/armv5/sclient $gocmd $golib
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
@ -6,10 +6,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
sclient "git.coolaj86.com/sclient.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
fmt.Fprintf(os.Stderr, "\nusage: go run sclient*.go <remote> <local>\n"+
|
fmt.Fprintf(os.Stderr, "\nusage: sclient <remote> <local>\n"+
|
||||||
"\n"+
|
"\n"+
|
||||||
" ex: sclient example.com 3000\n"+
|
" ex: sclient example.com 3000\n"+
|
||||||
" (sclient example.com:443 localhost:3000)\n"+
|
" (sclient example.com:443 localhost:3000)\n"+
|
||||||
|
@ -39,7 +41,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := &SclientOpts{}
|
opts := &sclient.PipeOpts{}
|
||||||
opts.RemotePort = 443
|
opts.RemotePort = 443
|
||||||
opts.LocalAddress = "localhost"
|
opts.LocalAddress = "localhost"
|
||||||
opts.InsecureSkipVerify = *insecure
|
opts.InsecureSkipVerify = *insecure
|
||||||
|
@ -85,7 +87,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sclient := &Sclient{}
|
sclient := &sclient.Tun{}
|
||||||
err := sclient.DialAndListen(opts)
|
err := sclient.DialAndListen(opts)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
fmt.Fprintf(os.Stderr, "%s\n", err)
|
10
sclient.go
10
sclient.go
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package sclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
@ -40,7 +40,7 @@ type Rwc interface {
|
||||||
RemoteAddr() net.Addr
|
RemoteAddr() net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
type SclientOpts struct {
|
type PipeOpts struct {
|
||||||
RemoteAddress string
|
RemoteAddress string
|
||||||
RemotePort int
|
RemotePort int
|
||||||
LocalAddress string
|
LocalAddress string
|
||||||
|
@ -48,7 +48,7 @@ type SclientOpts struct {
|
||||||
InsecureSkipVerify bool
|
InsecureSkipVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sclient struct{}
|
type Tun struct{}
|
||||||
|
|
||||||
func pipe(r Rwc, w Rwc, t string) {
|
func pipe(r Rwc, w Rwc, t string) {
|
||||||
buffer := make([]byte, 2048)
|
buffer := make([]byte, 2048)
|
||||||
|
@ -86,7 +86,7 @@ func pipe(r Rwc, w Rwc, t string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleConnection(remote string, conn Rwc, opts *SclientOpts) {
|
func handleConnection(remote string, conn Rwc, opts *PipeOpts) {
|
||||||
sclient, err := tls.Dial("tcp", remote,
|
sclient, err := tls.Dial("tcp", remote,
|
||||||
&tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify})
|
&tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify})
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ func handleConnection(remote string, conn Rwc, opts *SclientOpts) {
|
||||||
pipe(sclient, conn, "remote")
|
pipe(sclient, conn, "remote")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Sclient) DialAndListen(opts *SclientOpts) error {
|
func (*Tun) DialAndListen(opts *PipeOpts) error {
|
||||||
remote := opts.RemoteAddress + ":" + strconv.Itoa(opts.RemotePort)
|
remote := opts.RemoteAddress + ":" + strconv.Itoa(opts.RemotePort)
|
||||||
conn, err := tls.Dial("tcp", remote,
|
conn, err := tls.Dial("tcp", remote,
|
||||||
&tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify})
|
&tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify})
|
||||||
|
|
Loading…
Reference in New Issue