-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a service socket #603
Add a service socket #603
Conversation
} | ||
}) | ||
} | ||
} else if (line.indexOf("/clearban") === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/unglobalban or something like that would be more consistent naming.
Replace the IP address regex with net.isIPv4()
: https://nodejs.org/api/net.html#net_net_isipv4_input
07b41c5
to
4010ee9
Compare
Updated. |
@@ -75,5 +76,31 @@ function handleLine(line) { | |||
} | |||
} else if (line.indexOf("/reload-partitions") === 0) { | |||
sv.reloadPartitionMap(); | |||
} else if (line.indexOf("/globalban") === 0) { | |||
var args = line.split(" "); args.shift(); | |||
if (args.length === 2 && net.isIPv4(args[0]) || net.isIPv6(args[0])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operator precedence means that this is parsed as (args.length === 2 && net.isIPv4(args[0])) || net.isIPv6(args[0])
, also if you want to support both you can just check if net.isIP()
is nonzero.
f832ca5
to
3cd9d71
Compare
Updated and retested. |
Add one more command to the service commandline
@@ -45,6 +45,7 @@ process.stdin.on("data", function (data) { | |||
} | |||
}); | |||
|
|||
var net = require('net'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not unused. It's used to to validate user input, which was your suggestion over a regex.
Edit: I can change it to just import the one function though.
to enable out of band access to the process commandline