Skip to content

Commit 83f3ae9

Browse files
committed
Check IP whitelist on new connections
1 parent dcb3791 commit 83f3ae9

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,31 @@ The server should be run on the computer with the browser that you want to use.
88

99
### Config
1010

11-
Server config is simple, just edit server-conf.json and enter the port you want the server to listen on.
11+
Edit `server-conf.json` with the following options:
12+
13+
#### `listen`
14+
15+
The port the server will listen on.
16+
17+
#### `sources`
18+
19+
An array of allowed client IP addresses.
1220

1321
## Client
1422

1523
The client should be run on any computer which you want to open URLs from.
1624

1725
### Config
1826

19-
Client config is also simple. Edit client-conf.json with the IP/Hostname and port of the server.
27+
Edit `client-conf.json` with the IP/Hostname and port of the server.
2028

2129
## Misc
2230

2331
The server uses the following to open urls:
2432

25-
- xdg-open on GNU/Linux based systems
26-
- explorer.exe on Windows systems
27-
- open on OSX systems
28-
33+
- `xdg-open` on GNU/Linux based systems
34+
- `explorer.exe` on Windows systems
35+
- `open` on OSX systems
2936

3037
The included `URLBridge.reg` file can be used on Windows (tested on Windows 7) to set the default browser
3138
to be URL-Bridge. It assumes that URL-Bridge is located at `C:\URLBridge\` and that `nodejs.exe` is

server-conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"listen": 11223
2+
"listen": 11223,
3+
"sources": []
34
}

server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ fs.readFile(__dirname + '/server-conf.json', function (err, data) {
1616
var config = JSON.parse(data);
1717

1818
var server = net.createServer(function(socket) {
19+
20+
if (config.sources.indexOf(socket.remoteAddress) === -1) {
21+
socket.destroy();
22+
}
23+
1924
socket.on('data', function(data) {
2025
var url = data.toString()
2126
.replace(/[\s\r\n]+$/, '')

0 commit comments

Comments
 (0)