Allowing to bind on other IP Addresses through an environment variable. Writing the corresponding documentation.

This commit is contained in:
tomasgodoi 2017-08-28 17:15:42 -03:00
parent 4c0f211dac
commit b2f4d54ac2
2 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import base64
import hashlib import hashlib
import inspect import inspect
import json import json
import os
import os.path import os.path
import re import re
import select import select
@ -38,7 +39,7 @@ API_VERSION = 4
TICK_INTERVAL = 25 TICK_INTERVAL = 25
URL_TIMEOUT = 10 URL_TIMEOUT = 10
URL_UPGRADE = 'https://raw.githubusercontent.com/FooSoft/anki-connect/master/AnkiConnect.py' URL_UPGRADE = 'https://raw.githubusercontent.com/FooSoft/anki-connect/master/AnkiConnect.py'
NET_ADDRESS = '127.0.0.1' NET_ADDRESS = os.getenv('ANKICONNECT_BIND_ADDRESS', '127.0.0.1')
NET_BACKLOG = 5 NET_BACKLOG = 5
NET_PORT = 8765 NET_PORT = 8765

View File

@ -45,6 +45,8 @@ AnkiConnect exposes Anki features to external applications via an easy to use
initialize a minimal HTTP sever running on port 8765 every time Anki executes. Other applications (including browser initialize a minimal HTTP sever running on port 8765 every time Anki executes. Other applications (including browser
extensions) can then communicate with it via HTTP POST requests. extensions) can then communicate with it via HTTP POST requests.
By default, AnkiConnect will only bind the HTTP server to the `127.0.0.1.` IP Address, so you will only be able to access it from the same host on which it is running. If you need to access it over a network, you can set the environment variable `ANKICONNECT_BIND_ADDRESS` to change the binding address. For example, you can set it to `0.0.0.0` to bind it to all network interfaces on your host.
### Sample Invocation ### ### Sample Invocation ###
Every request consists of a JSON-encoded object containing an *action*, and a set of contextual *parameters*. A simple Every request consists of a JSON-encoded object containing an *action*, and a set of contextual *parameters*. A simple