-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolver.py
28 lines (22 loc) · 1.02 KB
/
resolver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import neo4j
def custom_resolver(socket_address):
# assert isinstance(socket_address, neo4j.Address)
if socket_address != ("example.com", 9999):
raise OSError(f"Unexpected socket address {socket_address!r}")
# You can return any neo4j.Address object
yield neo4j.Address(("google.com", 7687)) # IPv4
# yield neo4j.Address(("::1", 7687, 0, 0)) # IPv6
# yield neo4j.Address.parse("localhost:7687")
# yield neo4j.Address.parse("[::1]:7687")
# or any tuple that can be passed to neo4j.Address(...).
# This will initially be interpreted as IPv4, but DNS resolution
# will turn it into IPv6 if appropriate.
# yield "::1", 7687
# This will be interpreted as IPv6 directly, but DNS resolution will
# still happen.
# yield "::1", 7687, 0, 0
# yield "127.0.0.1", 7687
driver = neo4j.GraphDatabase.driver("neo4j://example.com:9999",
auth=("neo4j", "secret"),
resolver=custom_resolver)
driver.verify_connectivity()