|
1 | 1 | package main
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "fmt" |
5 |
| - "math/rand" |
6 | 4 | "os"
|
7 | 5 | "path"
|
8 |
| - "time" |
9 | 6 |
|
10 |
| - "github.com/brianvoe/gofakeit/v5" |
11 | 7 | "github.com/evan-buss/openbooks/server"
|
12 | 8 |
|
13 | 9 | "github.com/spf13/cobra"
|
14 | 10 | )
|
15 | 11 |
|
16 | 12 | func init() {
|
17 | 13 | rootCmd.AddCommand(serverCmd)
|
18 |
| - userName := generateUserName() |
19 | 14 |
|
20 | 15 | serverCmd.Flags().BoolP("log", "l", false, "Save raw IRC logs for each client connection.")
|
21 | 16 | serverCmd.Flags().BoolP("browser", "b", false, "Open the browser on server start.")
|
22 |
| - serverCmd.Flags().StringP("name", "n", userName, "Use a name that isn't randomly generated. One word only.") |
| 17 | + serverCmd.Flags().StringP("name", "n", generateUserName(), "Use a name that isn't randomly generated. One word only.") |
23 | 18 | serverCmd.Flags().StringP("port", "p", "5228", "Set the local network port for browser mode.")
|
24 | 19 | serverCmd.Flags().StringP("dir", "d", path.Join(os.TempDir(), "openbooks"), "The directory where eBooks are saved when persist enabled.")
|
25 | 20 | serverCmd.Flags().Bool("persist", false, "Persist eBooks in 'dir'. Default is to delete after sending.")
|
@@ -64,14 +59,6 @@ var serverCmd = &cobra.Command{
|
64 | 59 | },
|
65 | 60 | }
|
66 | 61 |
|
67 |
| -// Generate a random username to avoid IRC name collisions if multiple users are hosting |
68 |
| -// at the same time. |
69 |
| -func generateUserName() string { |
70 |
| - rand.Seed(time.Now().UnixNano()) |
71 |
| - gofakeit.Seed(int64(rand.Int())) |
72 |
| - return fmt.Sprintf("%s-%s", gofakeit.Adjective(), gofakeit.Noun()) |
73 |
| -} |
74 |
| - |
75 | 62 | func sanitizePath(basepath string) string {
|
76 | 63 | cleaned := path.Clean(basepath)
|
77 | 64 | if cleaned == "/" {
|
|
0 commit comments