Skip to content

Commit 5d59b91

Browse files
committed
add identitypath flag
1 parent e4beac9 commit 5d59b91

24 files changed

Lines changed: 325 additions & 261 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ dist
3535
db
3636
bin
3737
data
38-
node_modules
38+
node_modules
39+
identity.json

ceversi/main.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ import (
2020
)
2121

2222
var (
23-
flagServerURLs []string
24-
flagDiscovery bool
25-
flagBanMITM bool
26-
flagPort int
27-
flagBackendPort int
28-
flagName string
29-
flagHide bool
30-
flagDescription string
31-
flagTags string
32-
flagOwner string
33-
flagCServerPath string
23+
flagServerURLs []string
24+
flagDiscovery bool
25+
flagBanMITM bool
26+
flagPort int
27+
flagBackendPort int
28+
flagName string
29+
flagIdentityPath string
30+
flagHide bool
31+
flagDescription string
32+
flagTags string
33+
flagOwner string
34+
flagCServerPath string
3435
)
3536

3637
var rootCmd = &cobra.Command{
@@ -47,6 +48,7 @@ func init() {
4748
flags.IntVar(&flagPort, "port", 31744, "optional local HTTP port (negative to disable)")
4849
flags.IntVar(&flagBackendPort, "backend-port", 31745, "C server port")
4950
flags.StringVar(&flagName, "name", "ceversi", "backend display name")
51+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
5052
flags.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
5153
flags.StringVar(&flagDescription, "description", "Simple Othello/Reversi game written in C", "lease description")
5254
flags.StringVar(&flagOwner, "owner", "Ceversi", "lease owner")
@@ -88,10 +90,11 @@ func runCeversi(cmd *cobra.Command, args []string) error {
8890
mux.Handle("/", proxy)
8991

9092
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
91-
RelayURLs: append([]string(nil), flagServerURLs...),
92-
BanMITM: flagBanMITM,
93-
Discovery: flagDiscovery,
94-
Name: flagName,
93+
RelayURLs: append([]string(nil), flagServerURLs...),
94+
BanMITM: flagBanMITM,
95+
Discovery: flagDiscovery,
96+
Name: flagName,
97+
IdentityPath: flagIdentityPath,
9598
Metadata: types.LeaseMetadata{
9699
Description: flagDescription,
97100
Tags: utils.SplitCSV(flagTags),

chatter-bbs/main.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ var rootCmd = &cobra.Command{
2121
}
2222

2323
var (
24-
flagServerURLs string
25-
flagDiscovery bool
26-
flagBanMITM bool
27-
flagPort int
28-
flagName string
29-
flagHide bool
30-
flagDescription string
31-
flagTags string
32-
flagOwner string
24+
flagServerURLs string
25+
flagDiscovery bool
26+
flagBanMITM bool
27+
flagPort int
28+
flagName string
29+
flagIdentityPath string
30+
flagHide bool
31+
flagDescription string
32+
flagTags string
33+
flagOwner string
3334
)
3435

3536
func init() {
@@ -39,6 +40,7 @@ func init() {
3940
flags.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
4041
flags.IntVar(&flagPort, "port", -1, "optional local HTTP port (negative to disable)")
4142
flags.StringVar(&flagName, "name", "chatter-bbs", "backend display name")
43+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
4244
flags.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
4345
flags.StringVar(&flagDescription, "description", "Portal demo: Chatter BBS", "lease description")
4446
flags.StringVar(&flagOwner, "owner", "Chatter BBS", "lease owner")
@@ -66,10 +68,11 @@ func runChatter(cmd *cobra.Command, args []string) error {
6668
handler := NewHandler(displayAddr, flagName, func() string { return "Connected" })
6769

6870
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
69-
RelayURLs: utils.SplitCSV(flagServerURLs),
70-
BanMITM: flagBanMITM,
71-
Discovery: flagDiscovery,
72-
Name: flagName,
71+
RelayURLs: utils.SplitCSV(flagServerURLs),
72+
BanMITM: flagBanMITM,
73+
Discovery: flagDiscovery,
74+
Name: flagName,
75+
IdentityPath: flagIdentityPath,
7376
Metadata: types.LeaseMetadata{
7477
Description: flagDescription,
7578
Tags: utils.SplitCSV(flagTags),

distributed-web-server/manager/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var (
5555
flagBanMITM bool
5656
flagPort int
5757
flagName string
58+
flagIdentityPath string
5859
flagDescription string
5960
flagOwner string
6061
flagTags string
@@ -76,6 +77,7 @@ func init() {
7677
flags.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
7778
flags.IntVar(&flagPort, "port", parseIntEnv("MANAGER_PORT", 8080), "local HTTP port for the manager + portal binding [env: MANAGER_PORT]")
7879
flags.StringVar(&flagName, "name", getEnv("MANAGER_NAME", "distributed-web-manager"), "lease display name [env: MANAGER_NAME]")
80+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
7981
flags.StringVar(&flagDescription, "description", getEnv("MANAGER_DESCRIPTION", "High-performance distributed web manager"), "lease description [env: MANAGER_DESCRIPTION]")
8082
flags.StringVar(&flagOwner, "owner", getEnv("MANAGER_OWNER", "Distributed Manager"), "lease owner label [env: MANAGER_OWNER]")
8183
flags.StringVar(&flagTags, "tags", getEnv("MANAGER_TAGS", "distributed,worker,manager"), "comma-separated tags [env: MANAGER_TAGS]")
@@ -1045,10 +1047,11 @@ func runManagerCmd(cmd *cobra.Command, args []string) error {
10451047
}
10461048

10471049
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
1048-
RelayURLs: utils.SplitCSV(flagServerURLs),
1049-
BanMITM: flagBanMITM,
1050-
Discovery: flagDiscovery,
1051-
Name: flagName,
1050+
RelayURLs: utils.SplitCSV(flagServerURLs),
1051+
BanMITM: flagBanMITM,
1052+
Discovery: flagDiscovery,
1053+
Name: flagName,
1054+
IdentityPath: flagIdentityPath,
10521055
Metadata: types.LeaseMetadata{
10531056
Description: flagDescription,
10541057
Tags: utils.SplitCSV(flagTags),

doom/main.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ var rootCmd = &cobra.Command{
2323
}
2424

2525
var (
26-
flagServerURLs string
27-
flagDiscovery bool
28-
flagBanMITM bool
29-
flagPort int
30-
flagName string
31-
flagHide bool
32-
flagDescription string
33-
flagTags string
34-
flagOwner string
26+
flagServerURLs string
27+
flagDiscovery bool
28+
flagBanMITM bool
29+
flagPort int
30+
flagName string
31+
flagIdentityPath string
32+
flagHide bool
33+
flagDescription string
34+
flagTags string
35+
flagOwner string
3536
)
3637

3738
func init() {
@@ -41,6 +42,7 @@ func init() {
4142
flags.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
4243
flags.IntVar(&flagPort, "port", -1, "optional local HTTP port (negative to disable)")
4344
flags.StringVar(&flagName, "name", "doom", "backend display name")
45+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
4446
flags.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
4547
flags.StringVar(&flagDescription, "description", "Portal demo: Doom (served over portal HTTP backend)", "lease description")
4648
flags.StringVar(&flagOwner, "owner", "Doom", "lease owner")
@@ -66,10 +68,11 @@ func runDoom(cmd *cobra.Command, args []string) error {
6668
mux.Handle("/", withStaticHeaders(http.FileServer(http.FS(staticFS))))
6769

6870
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
69-
RelayURLs: utils.SplitCSV(flagServerURLs),
70-
BanMITM: flagBanMITM,
71-
Discovery: flagDiscovery,
72-
Name: flagName,
71+
RelayURLs: utils.SplitCSV(flagServerURLs),
72+
BanMITM: flagBanMITM,
73+
Discovery: flagDiscovery,
74+
Name: flagName,
75+
IdentityPath: flagIdentityPath,
7376
Metadata: types.LeaseMetadata{
7477
Description: flagDescription,
7578
Tags: utils.SplitCSV(flagTags),

emulator-js/main.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ var rootCmd = &cobra.Command{
2323
}
2424

2525
var (
26-
flagServerURLs string
27-
flagDiscovery bool
28-
flagBanMITM bool
29-
flagPort int
30-
flagName string
31-
flagHide bool
32-
flagDescription string
33-
flagTags string
34-
flagOwner string
26+
flagServerURLs string
27+
flagDiscovery bool
28+
flagBanMITM bool
29+
flagPort int
30+
flagName string
31+
flagIdentityPath string
32+
flagHide bool
33+
flagDescription string
34+
flagTags string
35+
flagOwner string
3536
)
3637

3738
func init() {
@@ -41,6 +42,7 @@ func init() {
4142
flags.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
4243
flags.IntVar(&flagPort, "port", -1, "optional local HTTP port (negative to disable)")
4344
flags.StringVar(&flagName, "name", "emulator-js", "backend display name")
45+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
4446
flags.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
4547
flags.StringVar(&flagDescription, "description", "Portal demo: EmulatorJS (served over portal HTTP backend)", "lease description")
4648
flags.StringVar(&flagOwner, "owner", "EmulatorJS", "lease owner")
@@ -73,10 +75,11 @@ func runEmulator(cmd *cobra.Command, args []string) error {
7375
mux.Handle("/docs/", withStaticHeaders(http.FileServer(http.FS(emulatorAssets))))
7476

7577
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
76-
RelayURLs: utils.SplitCSV(flagServerURLs),
77-
BanMITM: flagBanMITM,
78-
Discovery: flagDiscovery,
79-
Name: flagName,
78+
RelayURLs: utils.SplitCSV(flagServerURLs),
79+
BanMITM: flagBanMITM,
80+
Discovery: flagDiscovery,
81+
Name: flagName,
82+
IdentityPath: flagIdentityPath,
8083
Metadata: types.LeaseMetadata{
8184
Description: flagDescription,
8285
Tags: utils.SplitCSV(flagTags),

ffmpeg-converter/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var (
2929
flagBanMITM bool
3030
flagPort int
3131
flagName string
32+
flagIdentityPath string
3233
flagMaxSizeMB int64
3334
flagFFmpegWrapper string
3435
flagHide bool
@@ -44,6 +45,7 @@ func init() {
4445
f.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
4546
f.IntVar(&flagPort, "port", -1, "optional local HTTP port")
4647
f.StringVar(&flagName, "name", "ffmpeg-converter", "display name for relay lease")
48+
f.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
4749
f.Int64Var(&flagMaxSizeMB, "max-mb", 200, "max upload size in MB")
4850
f.StringVar(&flagFFmpegWrapper, "ffmpeg-wrapper", os.Getenv("FFMPEG_WRAPPER"), "optional command prefix to run ffmpeg (e.g. 'docker exec ffmpeg ffmpeg')")
4951
f.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
@@ -80,10 +82,11 @@ func run(cmd *cobra.Command, args []string) error {
8082
mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) })
8183

8284
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
83-
RelayURLs: utils.SplitCSV(flagServerURLs),
84-
BanMITM: flagBanMITM,
85-
Discovery: flagDiscovery,
86-
Name: flagName,
85+
RelayURLs: utils.SplitCSV(flagServerURLs),
86+
BanMITM: flagBanMITM,
87+
Discovery: flagDiscovery,
88+
Name: flagName,
89+
IdentityPath: flagIdentityPath,
8790
Metadata: types.LeaseMetadata{
8891
Description: flagDescription,
8992
Tags: utils.SplitCSV(flagTags),

gosuda-blog/main.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ var rootCmd = &cobra.Command{
2222
}
2323

2424
var (
25-
flagServerURLs string
26-
flagDiscovery bool
27-
flagBanMITM bool
28-
flagPort int
29-
flagName string
30-
flagDir string
31-
flagHide bool
32-
flagDescription string
33-
flagTags string
34-
flagOwner string
25+
flagServerURLs string
26+
flagDiscovery bool
27+
flagBanMITM bool
28+
flagPort int
29+
flagName string
30+
flagIdentityPath string
31+
flagDir string
32+
flagHide bool
33+
flagDescription string
34+
flagTags string
35+
flagOwner string
3536
)
3637

3738
func init() {
@@ -41,6 +42,7 @@ func init() {
4142
flags.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
4243
flags.IntVar(&flagPort, "port", -1, "optional local HTTP port (negative to disable)")
4344
flags.StringVar(&flagName, "name", "gosuda-blog", "Display name shown on server UI")
45+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
4446
flags.StringVar(&flagDir, "dir", "./gosuda-blog/dist", "Directory to serve (built static files)")
4547
flags.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
4648
flags.StringVar(&flagDescription, "description", "Portal demo: gosuda blog static site (relay HTTP backend)", "lease description")
@@ -73,10 +75,11 @@ func runBlog(cmd *cobra.Command, args []string) error {
7375
mux.Handle("/", fileServerWithSPA(flagDir))
7476

7577
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
76-
RelayURLs: utils.SplitCSV(flagServerURLs),
77-
BanMITM: flagBanMITM,
78-
Discovery: flagDiscovery,
79-
Name: flagName,
78+
RelayURLs: utils.SplitCSV(flagServerURLs),
79+
BanMITM: flagBanMITM,
80+
Discovery: flagDiscovery,
81+
Name: flagName,
82+
IdentityPath: flagIdentityPath,
8083
Metadata: types.LeaseMetadata{
8184
Description: flagDescription,
8285
Tags: utils.SplitCSV(flagTags),

http-backend/main.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ var rootCmd = &cobra.Command{
2121
}
2222

2323
var (
24-
flagServerURLs string
25-
flagDiscovery bool
26-
flagBanMITM bool
27-
flagPort int
28-
flagName string
29-
flagHide bool
30-
flagDescription string
31-
flagTags string
32-
flagOwner string
24+
flagServerURLs string
25+
flagDiscovery bool
26+
flagBanMITM bool
27+
flagPort int
28+
flagName string
29+
flagIdentityPath string
30+
flagHide bool
31+
flagDescription string
32+
flagTags string
33+
flagOwner string
3334
)
3435

3536
func init() {
@@ -39,6 +40,7 @@ func init() {
3940
flags.BoolVar(&flagBanMITM, "ban-mitm", utils.ResolveBoolEnv(false, "BAN_MITM"), "ban relay when MITM self-probe detects TLS termination [env: BAN_MITM]")
4041
flags.IntVar(&flagPort, "port", -1, "optional local HTTP port (negative to disable)")
4142
flags.StringVar(&flagName, "name", "example-backend", "backend display name shown on server UI")
43+
flags.StringVar(&flagIdentityPath, "identity-path", "identity.json", "optional path to load/save the portal identity")
4244
flags.BoolVar(&flagHide, "hide", false, "hide this lease from portal listings")
4345
flags.StringVar(&flagDescription, "description", "Portal demo client", "lease description")
4446
flags.StringVar(&flagOwner, "owner", "Example Backend", "lease owner")
@@ -57,10 +59,11 @@ func runClient(cmd *cobra.Command, args []string) error {
5759

5860
handler := NewHandler(flagName)
5961
exposure, err := sdk.Expose(ctx, sdk.ExposeConfig{
60-
RelayURLs: utils.SplitCSV(flagServerURLs),
61-
BanMITM: flagBanMITM,
62-
Discovery: flagDiscovery,
63-
Name: flagName,
62+
RelayURLs: utils.SplitCSV(flagServerURLs),
63+
BanMITM: flagBanMITM,
64+
Discovery: flagDiscovery,
65+
Name: flagName,
66+
IdentityPath: flagIdentityPath,
6467
Metadata: types.LeaseMetadata{
6568
Description: flagDescription,
6669
Tags: utils.SplitCSV(flagTags),

0 commit comments

Comments
 (0)