Skip to content

Commit 3e8070d

Browse files
committed
Added README and fine tunning of params
1 parent 9ac3784 commit 3e8070d

File tree

7 files changed

+341
-2
lines changed

7 files changed

+341
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
dist/

.goreleaser.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
project_name: outsystemscc
2+
before:
3+
hooks:
4+
- go mod tidy
5+
- go generate ./...
6+
builds:
7+
- env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- linux
11+
dockers:
12+
- image_templates: ["outsystems/{{ .ProjectName }}:{{ .Version }}"]
13+
build_flag_templates:
14+
- --platform=linux/amd64
15+
- --label=org.opencontainers.image.title=OutSystems Cloud Connector
16+
- --label=org.opencontainers.image.description=OutSystems Cloud Connector
17+
- --label=org.opencontainers.image.url=https://github.com/outsystems/cloud-connector
18+
- --label=org.opencontainers.image.source=https://github.com/outsystems/cloud-connector
19+
- --label=org.opencontainers.image.version={{ .Version }}
20+
- --label=org.opencontainers.image.created={{ .Date }}
21+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
22+
checksum:
23+
name_template: 'checksums.txt'
24+
snapshot:
25+
name_template: "{{ incpatch .Version }}-next"
26+
changelog:
27+
sort: asc
28+
filters:
29+
exclude:
30+
- '^docs:'
31+
- '^test:'

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Dockerfile
2+
FROM alpine
3+
COPY outsystemscc /app
4+
ENTRYPOINT ["/app"]

README.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,83 @@
1-
# cloud-connector
2-
OutSystems Cloud Connector
1+
# OutSystems Cloud Connector
2+
3+
The OutSystems Cloud Connector (`outsystemscc`) allows applications running in the OutSystems cloud to securely access remote services running in a private network through the OutSystems Secure Gateway. It is based in the open source component [chisel](https://github.com/jpillora/chisel), which is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH.
4+
5+
With `outsystemscc` you establish a secure tunnel from your private network (e.g. on-prem or private cloud) to the applications running in OutSystems cloud, while keeping full control and auditability of what it is exposed to your applications.
6+
7+
## Install
8+
9+
### Binaries
10+
Download the latest release from the [releases page](https://github.com/OutSystems/cloud-connector/releases/latest).
11+
Unzip/untar and copy the executable to the desired location, for example:
12+
```sh
13+
tar -xzf outsystemscc_1.0.0_linux_amd64.tar.gz
14+
mv outsystemscc /usr/local/bin
15+
./outsystemscc --help
16+
```
17+
18+
### Docker
19+
20+
```sh
21+
docker run --rm -it outsystems/outsystemscc --help
22+
```
23+
24+
## Usage
25+
```plain
26+
Usage: outsystemscc [options] <server> <remote> [remote] [remote] ...
27+
28+
<server> is the URL to the server.
29+
30+
<remote>s are remote connections tunneled through the server, each of
31+
which come in the form:
32+
33+
R:<local-port>:<remote-host>:<remote-port>
34+
35+
which does reverse port forwarding, sharing <remote-host>:<remote-port>
36+
from the client to the server's <local-port>.
37+
38+
example remotes
39+
40+
R:2222:localhost:22
41+
R:8080:10.0.0.1:80
42+
43+
Options:
44+
45+
--keepalive, An optional keepalive interval. Since the underlying
46+
transport is HTTP, in many instances we'll be traversing through
47+
proxies, often these proxies will close idle connections. You must
48+
specify a time with a unit, for example '5s' or '2m'. Defaults
49+
to '25s' (set to 0s to disable).
50+
51+
--max-retry-count, Maximum number of times to retry before exiting.
52+
Defaults to unlimited.
53+
54+
--max-retry-interval, Maximum wait time before retrying after a
55+
disconnection. Defaults to 5 minutes.
56+
57+
--proxy, An optional HTTP CONNECT or SOCKS5 proxy which will be
58+
used to reach the server. Authentication can be specified
59+
inside the URL.
60+
For example, http://admin:[email protected]:8081
61+
or: socks://admin:[email protected]:1080
62+
63+
--header, Set a custom header in the form "HeaderName: HeaderContent".
64+
Can be used multiple times. (e.g --header "Foo: Bar" --header "Hello: World")
65+
66+
--hostname, Optionally set the 'Host' header (defaults to the host
67+
found in the server url).
68+
69+
--pid Generate pid file in current working directory
70+
71+
-v, Enable verbose logging
72+
73+
--help, This help text
74+
75+
Signals:
76+
The outsystemscc process is listening for:
77+
a SIGUSR2 to print process stats, and
78+
a SIGHUP to short-circuit the client reconnect timer
79+
```
80+
81+
## License
82+
83+
[MIT](https://github.com/outsystems/cloud-connector/blob/master/LICENSE) © OutSystems

go.mod

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module github.com/outsystems/cloud-connector
2+
3+
require github.com/jpillora/chisel v1.7.7
4+
5+
require (
6+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 // indirect
7+
github.com/fsnotify/fsnotify v1.4.9 // indirect
8+
github.com/gorilla/websocket v1.4.2 // indirect
9+
github.com/jpillora/backoff v1.0.0 // indirect
10+
github.com/jpillora/sizestr v1.0.0 // indirect
11+
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
12+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
13+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
14+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
15+
)
16+
17+
replace github.com/jpillora/chisel => github.com/outsystems/chisel v1.7.7
18+
19+
go 1.18

go.sum

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2/go.mod h1:jnzFpU88PccN/tPPhCpnNU8mZphvKxYM9lLNkd8e+os=
2+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
3+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
4+
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
5+
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
6+
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
7+
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
8+
github.com/jpillora/ansi v1.0.2/go.mod h1:D2tT+6uzJvN1nBVQILYWkIdq7zG+b5gcFN5WI/VyjMY=
9+
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
10+
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
11+
github.com/jpillora/requestlog v1.0.0/go.mod h1:HTWQb7QfDc2jtHnWe2XEIEeJB7gJPnVdpNn52HXPvy8=
12+
github.com/jpillora/sizestr v1.0.0 h1:4tr0FLxs1Mtq3TnsLDV+GYUWG7Q26a6s+tV5Zfw2ygw=
13+
github.com/jpillora/sizestr v1.0.0/go.mod h1:bUhLv4ctkknatr6gR42qPxirmd5+ds1u7mzD+MZ33f0=
14+
github.com/outsystems/chisel v1.7.7 h1:igP2UIsbY7tKPUm8rfZWf99b8KiWTUnHz04rzYMIjvk=
15+
github.com/outsystems/chisel v1.7.7/go.mod h1:X3ZzJDlOSlkMLVY3DMsdrd03rMtugLYk2IOUhvX0SXo=
16+
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
17+
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
18+
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
19+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
20+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
21+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
22+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
23+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
24+
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
25+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
26+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
27+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
28+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
29+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
30+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
31+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
32+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
33+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
34+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
35+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

main.go

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"io/ioutil"
7+
"log"
8+
"net/http"
9+
"os"
10+
"runtime"
11+
"strconv"
12+
"strings"
13+
"time"
14+
15+
chclient "github.com/jpillora/chisel/client"
16+
"github.com/jpillora/chisel/share/cos"
17+
)
18+
19+
var (
20+
version = "dev" // Set by goreleaser
21+
)
22+
23+
func main() {
24+
client(os.Args[1:])
25+
}
26+
27+
func generatePidFile() {
28+
pid := []byte(strconv.Itoa(os.Getpid()))
29+
if err := ioutil.WriteFile("outsystemscc.pid", pid, 0644); err != nil {
30+
log.Fatal(err)
31+
}
32+
}
33+
34+
type headerFlags struct {
35+
http.Header
36+
}
37+
38+
func (flag *headerFlags) String() string {
39+
out := ""
40+
for k, v := range flag.Header {
41+
out += fmt.Sprintf("%s: %s\n", k, v)
42+
}
43+
return out
44+
}
45+
46+
func (flag *headerFlags) Set(arg string) error {
47+
index := strings.Index(arg, ":")
48+
if index < 0 {
49+
return fmt.Errorf(`Invalid header (%s). Should be in the format "HeaderName: HeaderContent"`, arg)
50+
}
51+
if flag.Header == nil {
52+
flag.Header = http.Header{}
53+
}
54+
key := arg[0:index]
55+
value := arg[index+1:]
56+
flag.Header.Set(key, strings.TrimSpace(value))
57+
return nil
58+
}
59+
60+
var clientHelp = `
61+
Usage: outsystemscc [options] <server> <remote> [remote] [remote] ...
62+
63+
<server> is the URL to the server.
64+
65+
<remote>s are remote connections tunneled through the server, each of
66+
which come in the form:
67+
68+
R:<local-port>:<remote-host>:<remote-port>
69+
70+
which does reverse port forwarding, sharing <remote-host>:<remote-port>
71+
from the client to the server's <local-port>.
72+
73+
example remotes
74+
75+
R:2222:localhost:22
76+
R:8080:10.0.0.1:80
77+
78+
Options:
79+
80+
--keepalive, An optional keepalive interval. Since the underlying
81+
transport is HTTP, in many instances we'll be traversing through
82+
proxies, often these proxies will close idle connections. You must
83+
specify a time with a unit, for example '5s' or '2m'. Defaults
84+
to '25s' (set to 0s to disable).
85+
86+
--max-retry-count, Maximum number of times to retry before exiting.
87+
Defaults to unlimited.
88+
89+
--max-retry-interval, Maximum wait time before retrying after a
90+
disconnection. Defaults to 5 minutes.
91+
92+
--proxy, An optional HTTP CONNECT or SOCKS5 proxy which will be
93+
used to reach the server. Authentication can be specified
94+
inside the URL.
95+
For example, http://admin:[email protected]:8081
96+
or: socks://admin:[email protected]:1080
97+
98+
--header, Set a custom header in the form "HeaderName: HeaderContent".
99+
Can be used multiple times. (e.g --header "Foo: Bar" --header "Hello: World")
100+
101+
--hostname, Optionally set the 'Host' header (defaults to the host
102+
found in the server url).
103+
104+
--pid Generate pid file in current working directory
105+
106+
-v, Enable verbose logging
107+
108+
--help, This help text
109+
110+
Signals:
111+
The outsystemscc process is listening for:
112+
a SIGUSR2 to print process stats, and
113+
a SIGHUP to short-circuit the client reconnect timer
114+
115+
Version:
116+
` + version + ` (` + runtime.Version() + `)
117+
`
118+
119+
func client(args []string) {
120+
flags := flag.NewFlagSet("client", flag.ContinueOnError)
121+
config := chclient.Config{Headers: http.Header{}}
122+
flags.DurationVar(&config.KeepAlive, "keepalive", 25*time.Second, "")
123+
flags.IntVar(&config.MaxRetryCount, "max-retry-count", -1, "")
124+
flags.DurationVar(&config.MaxRetryInterval, "max-retry-interval", 0, "")
125+
flags.StringVar(&config.Proxy, "proxy", "", "")
126+
flags.Var(&headerFlags{config.Headers}, "header", "")
127+
hostname := flags.String("hostname", "", "")
128+
pid := flags.Bool("pid", false, "")
129+
verbose := flags.Bool("v", false, "")
130+
flags.Usage = func() {
131+
fmt.Print(clientHelp)
132+
os.Exit(0)
133+
}
134+
flags.Parse(args)
135+
//pull out options, put back remaining args
136+
args = flags.Args()
137+
if len(args) < 2 {
138+
log.Fatalf("A server and least one remote is required")
139+
}
140+
config.Server = args[0]
141+
config.Remotes = args[1:]
142+
//default auth
143+
if config.Auth == "" {
144+
config.Auth = os.Getenv("AUTH")
145+
}
146+
//move hostname onto headers
147+
if *hostname != "" {
148+
config.Headers.Set("Host", *hostname)
149+
}
150+
//ready
151+
c, err := chclient.NewClient(&config)
152+
if err != nil {
153+
log.Fatal(err)
154+
}
155+
c.Debug = *verbose
156+
if *pid {
157+
generatePidFile()
158+
}
159+
go cos.GoStats()
160+
ctx := cos.InterruptContext()
161+
if err := c.Start(ctx); err != nil {
162+
log.Fatal(err)
163+
}
164+
if err := c.Wait(); err != nil {
165+
log.Fatal(err)
166+
}
167+
}

0 commit comments

Comments
 (0)