mirror of Walter-Sparrow / lunar-tear
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add --grpc-port support

+28 -19
+14 -12
README.md
··· 67 67 68 68 ```bash 69 69 cd server 70 - sudo go run ./cmd/lunar-tear \ 70 + go run ./cmd/lunar-tear \ 71 71 --host 10.0.2.2 \ 72 - --http-port 8080 72 + --http-port 8080 \ 73 + --grpc-port 8003 73 74 ``` 74 75 75 - `sudo` is needed because gRPC binds to port 443 (privileged). On Linux you can use `setcap` instead: 76 + The default gRPC port is 443, which requires `sudo` (privileged port). Use `--grpc-port` with a high port to avoid this. If you do need port 443, either use `sudo` or grant the binary the capability on Linux: 76 77 77 78 ```bash 78 79 go build -o lunar-tear ./cmd/lunar-tear ··· 82 83 83 84 ### Ports 84 85 85 - | Protocol | Port | Notes | 86 - | -------- | ---- | ---------------------------------------------------- | 87 - | gRPC | 443 | hardcoded by the client, not configurable | 88 - | HTTP | 8080 | Octo asset API + game web pages (`--http-port` flag) | 86 + | Protocol | Port | Notes | 87 + | -------- | ---- | ----------------------------------------------------------- | 88 + | gRPC | 443 | default; configurable with `--grpc-port` (requires patched client) | 89 + | HTTP | 8080 | Octo asset API + game web pages (`--http-port` flag) | 89 90 90 91 ### Flags 91 92 92 - | Flag | Default | Description | 93 - | ------------- | ------------ | ------------------------------- | 94 - | `--host` | `127.0.0.1` | hostname/IP given to the client | 95 - | `--http-port` | `8080` | HTTP/Octo server port | 96 - | `--db` | `db/game.db` | SQLite database path | 93 + | Flag | Default | Description | 94 + | ------------- | ------------ | ---------------------------------------------------- | 95 + | `--host` | `127.0.0.1` | hostname/IP given to the client | 96 + | `--http-port` | `8080` | HTTP/Octo server port | 97 + | `--grpc-port` | `443` | gRPC server port (client must be patched to match) | 98 + | `--db` | `db/game.db` | SQLite database path | 97 99 98 100 ### Docker 99 101
+9 -5
server/cmd/lunar-tear/grpc.go
··· 37 37 38 38 func startGRPC( 39 39 host string, 40 + grpcPort int, 40 41 octoURL string, 41 42 userStore interface { 42 43 store.UserRepository ··· 64 65 sideStoryCatalog *masterdata.SideStoryCatalog, 65 66 bigHuntCatalog *masterdata.BigHuntCatalog, 66 67 ) { 67 - lis, err := net.Listen("tcp", ":443") 68 + addr := fmt.Sprintf(":%d", grpcPort) 69 + lis, err := net.Listen("tcp", addr) 68 70 if err != nil { 69 - log.Fatalf("failed to listen on :443: %v", err) 71 + log.Fatalf("failed to listen on %s: %v", addr, err) 70 72 } 71 73 lis = loggingListener{Listener: lis} 72 74 ··· 77 79 78 80 registerServices(grpcServer, 79 81 host, 82 + grpcPort, 80 83 octoURL, 81 84 userStore, 82 85 questEngine, ··· 104 107 105 108 reflection.Register(grpcServer) 106 109 107 - log.Printf("gRPC server listening on :443") 108 - log.Printf("client host address: %s:443", host) 110 + log.Printf("gRPC server listening on %s", addr) 111 + log.Printf("client host address: %s:%d", host, grpcPort) 109 112 110 113 if err := grpcServer.Serve(lis); err != nil { 111 114 log.Fatalf("failed to serve: %v", err) ··· 115 118 func registerServices( 116 119 srv *grpc.Server, 117 120 host string, 121 + grpcPort int, 118 122 octoURL string, 119 123 userStore interface { 120 124 store.UserRepository ··· 145 149 pb.RegisterBannerServiceServer(srv, service.NewBannerServiceServer(gachaEntries)) 146 150 pb.RegisterUserServiceServer(srv, service.NewUserServiceServer(userStore, userStore)) 147 151 pb.RegisterBattleServiceServer(srv, service.NewBattleServiceServer(userStore, userStore)) 148 - pb.RegisterConfigServiceServer(srv, service.NewConfigServiceServer(host, int32(443), octoURL)) 152 + pb.RegisterConfigServiceServer(srv, service.NewConfigServiceServer(host, int32(grpcPort), octoURL)) 149 153 pb.RegisterDataServiceServer(srv, service.NewDataServiceServer(userStore, userStore)) 150 154 pb.RegisterTutorialServiceServer(srv, service.NewTutorialServiceServer(userStore, userStore, questEngine)) 151 155 pb.RegisterGachaServiceServer(srv, service.NewGachaServiceServer(userStore, userStore, gachaEntries, gachaHandler))
+2
server/cmd/lunar-tear/main.go
··· 16 16 17 17 func main() { 18 18 httpPort := flag.Int("http-port", 8080, "HTTP server port (Octo API)") 19 + grpcPort := flag.Int("grpc-port", 443, "gRPC server port") 19 20 host := flag.String("host", "127.0.0.1", "hostname the client will connect to") 20 21 dbPath := flag.String("db", "db/game.db", "SQLite database path") 21 22 flag.Parse() ··· 165 166 166 167 startGRPC( 167 168 *host, 169 + *grpcPort, 168 170 octoURL, 169 171 userStore, 170 172 questHandler,
+2 -1
server/docker-compose.yaml
··· 5 5 environment: 6 6 LUNAR_HOST: 127.0.0.1 7 7 LUNAR_HTTP_PORT: 8080 8 + LUNAR_GRPC_PORT: 8003 8 9 volumes: 9 10 - ./assets:/opt/lunar-tear/assets 10 11 - ./db:/opt/lunar-tear/db 11 12 ports: 12 - - 443:443 # grpc, hardcoded by the client, not configurable 13 + - 8003:8003 13 14 - 8080:8080 14 15
+1 -1
server/entrypoint.sh
··· 4 4 mkdir -p db 5 5 goose -dir migrations sqlite3 db/game.db up 6 6 7 - exec ./lunar-tear --host "${LUNAR_HOST}" --http-port "${LUNAR_HTTP_PORT}" 7 + exec ./lunar-tear --host "${LUNAR_HOST}" --http-port "${LUNAR_HTTP_PORT}" --grpc-port "${LUNAR_GRPC_PORT:-443}"