update examples
This commit is contained in:
parent
d8bbfc3d75
commit
cb63ae35a9
|
@ -78,7 +78,8 @@ Authorize a device:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
my_subdomain="xxxx"
|
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 "Authorization: Bearer ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{ "slug": "'$my_subdomain'" }'
|
-d '{ "slug": "'$my_subdomain'" }'
|
||||||
|
|
|
@ -243,7 +243,7 @@ func main() {
|
||||||
|
|
||||||
done := make(chan error)
|
done := make(chan error)
|
||||||
for _, addr := range bindAddrs {
|
for _, addr := range bindAddrs {
|
||||||
go func() {
|
go func(addr string) {
|
||||||
fmt.Printf("Listening on %s\n", addr)
|
fmt.Printf("Listening on %s\n", addr)
|
||||||
ln, err := net.Listen("tcp", addr)
|
ln, err := net.Listen("tcp", addr)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
@ -256,7 +256,7 @@ func main() {
|
||||||
done <- err
|
done <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
//connected := make(chan net.Conn)
|
//connected := make(chan net.Conn)
|
||||||
|
@ -296,7 +296,7 @@ func main() {
|
||||||
}()
|
}()
|
||||||
//connected <- tun
|
//connected <- tun
|
||||||
//tun := <-connected
|
//tun := <-connected
|
||||||
fmt.Printf("Listening at %s\n", *relay)
|
fmt.Printf("Listening through %s\n", *relay)
|
||||||
err = telebit.ListenAndServe(tun, mux)
|
err = telebit.ListenAndServe(tun, mux)
|
||||||
log.Fatal("Closed server: ", err)
|
log.Fatal("Closed server: ", err)
|
||||||
done <- err
|
done <- err
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
MGMT_BASEURL=http://devices.example.com:3010
|
||||||
|
CLIENT_SUBJECT=newbie
|
||||||
RELAY=wss://devices.example.com:8443
|
RELAY=wss://devices.example.com:8443
|
||||||
SECRET=xxxxxxxxxxxxxxxx
|
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
|
||||||
|
|
|
@ -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'" }'
|
|
@ -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"
|
|
@ -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
|
Loading…
Reference in New Issue