Skip to content

Commit ee3a2e2

Browse files
authored
Merge pull request #205 from cabal-club/support-port
add --port arg + preferredPort to config for custom port
2 parents 030db17 + 9625844 commit ee3a2e2

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ This will run cabal without a UI. You can use this to seed a cabal (e.g. on a VP
8787
cabal <key> --seed
8888
```
8989

90+
#### Custom port
91+
If you have a tightly configured firewall and need to port-forward a port, the default port Cabal uses is port `13331`.
92+
You can change this with the `--port` flag, or setting `preferredPort` in your .cabal.yml config file.
93+
94+
```
95+
cabal <key> --seed --port 7331
96+
```
97+
9098
## Commands
9199
```py
92100
/add, /cabal

cli.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var usage = `Usage
6060
6161
Options:
6262
--seed Start a headless seed for the specified cabal key
63+
--port Listen for cabal traffic on the passed in port (default: 13331)
6364
6465
--new Start a new cabal
6566
--nick Your nickname
@@ -112,6 +113,7 @@ if (!fs.existsSync(rootconfig)) {
112113
saveConfig(rootconfig, {
113114
cabals: [],
114115
aliases: {},
116+
preferredPort: 0,
115117
cache: {},
116118
frontend: {
117119
messageTimeformat: defaultMessageTimeformat,
@@ -130,6 +132,7 @@ try {
130132
}
131133
if (!config.cabals) { config.cabals = [] }
132134
if (!config.aliases) { config.aliases = {} }
135+
if (!config.preferredPort) { config.preferredPort = 0 }
133136
if (!config.cache) { config.cache = {} }
134137
if (!config.frontend) { config.frontend = {} }
135138
if (!config.frontend.messageTimeformat) {
@@ -149,7 +152,8 @@ const client = new Client({
149152
maxFeeds: maxFeeds,
150153
config: {
151154
dbdir: archivesdir,
152-
temp: args.temp
155+
temp: args.temp,
156+
preferredPort: args.port || config.preferredPort
153157
},
154158
commands: {
155159
// todo: custom commands
@@ -367,6 +371,16 @@ if (args.alias && args.key) {
367371
process.exit(0)
368372
}
369373

374+
if (args.port) {
375+
let port = parseInt(args.port)
376+
if (isNaN(port) || port < 0 || port > 65535) {
377+
logError(`${args.port} is not a valid port number`)
378+
process.exit(1)
379+
}
380+
args.port = port
381+
}
382+
383+
370384
if (args.key) {
371385
// If a key is provided, place it at the top of the keys provided from the config
372386
cabalKeys.unshift(args.key)

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"dependencies": {
99
"ansi-escapes": "^4.3.1",
10-
"cabal-client": "^6.2.5",
10+
"cabal-client": "^6.2.7",
1111
"chalk": "^4.0.0",
1212
"js-yaml": "^3.13.1",
1313
"minimist": "^1.2.5",

0 commit comments

Comments
 (0)