From b2f4d54ac2afba3ba1519c85421850819154ae29 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Mon, 28 Aug 2017 17:15:42 -0300 Subject: [PATCH] Allowing to bind on other IP Addresses through an environment variable. Writing the corresponding documentation. --- AnkiConnect.py | 3 ++- README.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index b5f2774..3a05908 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -21,6 +21,7 @@ import base64 import hashlib import inspect import json +import os import os.path import re import select @@ -38,7 +39,7 @@ API_VERSION = 4 TICK_INTERVAL = 25 URL_TIMEOUT = 10 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_PORT = 8765 diff --git a/README.md b/README.md index 219a110..b5c0f8e 100644 --- a/README.md +++ b/README.md @@ -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 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 ### Every request consists of a JSON-encoded object containing an *action*, and a set of contextual *parameters*. A simple