37
37
sqlitefile = flag .String ("sqlitedb" , "" , "path of SQLite database to store links" )
38
38
dev = flag .String ("dev-listen" , "" , "if non-empty, listen on this addr and run in dev mode; auto-set sqlitedb if empty and don't use tsnet" )
39
39
snapshot = flag .String ("snapshot" , "" , "file path of snapshot file" )
40
+ hostname = flag .String ("hostname" , "go" , "service name (defaults to 'go')" )
40
41
)
41
42
42
43
var stats struct {
@@ -112,8 +113,12 @@ func Run() error {
112
113
log .Fatal (http .ListenAndServe (* dev , nil ))
113
114
}
114
115
116
+ if * hostname == "" {
117
+ return errors .New ("--hostname, if specified, cannot be empty" )
118
+ }
119
+
115
120
srv := & tsnet.Server {
116
- Hostname : "go" ,
121
+ Hostname : * hostname ,
117
122
Logf : func (format string , args ... any ) {},
118
123
}
119
124
if * verbose {
@@ -129,7 +134,7 @@ func Run() error {
129
134
return err
130
135
}
131
136
132
- log .Printf ("Serving http://go / ..." )
137
+ log .Printf ("Serving http://%s / ..." , * hostname )
133
138
if err := http .Serve (l80 , nil ); err != nil {
134
139
return err
135
140
}
@@ -353,7 +358,7 @@ type expandEnv struct {
353
358
var expandFuncMap = texttemplate.FuncMap {
354
359
"PathEscape" : url .PathEscape ,
355
360
"QueryEscape" : url .QueryEscape ,
356
- "TrimSuffix" : strings .TrimSuffix ,
361
+ "TrimSuffix" : strings .TrimSuffix ,
357
362
}
358
363
359
364
// expandLink returns the expanded long URL to redirect to, executing any
0 commit comments