update examples

This commit is contained in:
AJ ONeal 2020-06-29 02:43:46 -06:00
parent d8bbfc3d75
commit cb63ae35a9
6 changed files with 54 additions and 5 deletions

View File

@ -78,7 +78,8 @@ Authorize a device:
```bash
my_subdomain="xxxx"
curl -X POST http://mgmt.example.com:3010/api/devices \
my_mgmt_host=http://mgmt.example.com:3010
curl -X POST $my_mgmt_host/api/devices \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{ "slug": "'$my_subdomain'" }'

View File

@ -243,7 +243,7 @@ func main() {
done := make(chan error)
for _, addr := range bindAddrs {
go func() {
go func(addr string) {
fmt.Printf("Listening on %s\n", addr)
ln, err := net.Listen("tcp", addr)
if nil != err {
@ -256,7 +256,7 @@ func main() {
done <- err
return
}
}()
}(addr)
}
//connected := make(chan net.Conn)
@ -296,7 +296,7 @@ func main() {
}()
//connected <- tun
//tun := <-connected
fmt.Printf("Listening at %s\n", *relay)
fmt.Printf("Listening through %s\n", *relay)
err = telebit.ListenAndServe(tun, mux)
log.Fatal("Closed server: ", err)
done <- err

View File

@ -1,3 +1,5 @@
MGMT_BASEURL=http://devices.example.com:3010
CLIENT_SUBJECT=newbie
RELAY=wss://devices.example.com:8443
SECRET=xxxxxxxxxxxxxxxx
LOCALS=https:xxx.devices.example.com:3000,http:xxx.devices.example.com:3000
LOCALS=https:$CLIENT_SUBJECT.devices.example.com:3000,http:$CLIENT_SUBJECT.devices.example.com:3000

View File

@ -0,0 +1,9 @@
source .env
TOKEN=$(go run -mod=vendor cmd/signjwt/*.go $SECRET)
MGMT_BASEURL=${MGMT_BASEURL:-"http://mgmt.example.com:3010"}
CLIENT_SUBJECT=${CLIENT_SUBJECT:-"newbie"}
curl -X POST $MGMT_BASEURL/api/devices \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{ "slug": "'$CLIENT_SUBJECT'" }'

18
examples/run-as-client.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -e
set -u
go generate -mod=vendor ./...
go build -mod=vendor -o telebit cmd/telebit/*.go
source .env
ACME_RELAY_BASEURL=${ACME_RELAY_BASEURL:-"https://devices.examples.com"}
AUTH_BASEURL=${AUTH_BASEURL:-"https://devices.examples.com"}
CLIENT_SECRET=${CLIENT_SECRET:-"yyyyyyyyyyyyyyyy"}
./telebit --acme-agree=true \
--acme-relay $ACME_RELAY_BASEURL/api \
--auth-url $AUTH_BASEURL/api \
--app-id test-id --secret "$CLIENT_SECRET"

19
examples/run-as-server.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
set -u
go generate -mod=vendor ./...
go build -mod=vendor -o telebit cmd/telebit/*.go
source .env
ADMIN_HOSTNAME=${ADMIN_HOSTNAME:-"devices.example.com"}
AUTH_BASEURL=${AUTH_BASEURL:-"https://devices.example.com"}
SECRET=${SECRET:-"xxxxxxxxxxxxxxxx"}
./telebit --acme-agree=true \
--admin-hostname $ADMIN_HOSTNAME \
--auth-url $AUTH_BASEURL/api \
--secret "$SECRET" \
--listen 3020,3030