Commit 78eb9118 authored by Killian Lufau's avatar Killian Lufau

modify user-agent to identity system of a node

The main goal of this is the check if we should keep supporting
older distributions.
parent 8401ce4e
......@@ -19,7 +19,7 @@ Authenticated communication:
- the one of the last handshake (hello)
"""
import base64, hmac, hashlib, httplib, inspect, json, logging
import mailbox, os, random, select, smtplib, socket, sqlite3
import mailbox, os, platform, random, select, smtplib, socket, sqlite3
import string, struct, sys, threading, time, weakref, zlib
from collections import defaultdict, deque
from datetime import datetime
......@@ -240,6 +240,8 @@ class RegistryServer(object):
self.timeout = not_after and not_after + GRACE_PERIOD
def handle_request(self, request, method, kw):
with self.lock:
self.client_headers = request.headers
m = getattr(self, method)
if hasattr(method, '_private'):
authorized_origin = self.config.authorized_origin
......@@ -510,11 +512,17 @@ class RegistryServer(object):
# (in case 'peers' is empty).
peer = self.prefix
with self.lock:
forward = self.client_headers.get("X-Forwarded-For")
addr = forward if forward else self.client_headers.get("host")
user_agent = self.client_headers.get('user-agent')
msg = self._queryAddress(peer)
if msg is None:
return
cert = self.getCert(cn)
msg = "%s %s" % (peer, msg)
logging.info("Client %s (%s, %s) asked a bootstrap peer",
utils.ipFromBin(x509.networkFromCa(self.cert.ca) + cn),
addr, user_agent)
logging.info("Sending bootstrap peer: %s", msg)
return x509.encrypt(cert, msg)
......@@ -640,7 +648,7 @@ class RegistryServer(object):
class RegistryClient(object):
_hmac = None
user_agent = "re6stnet/" + version.version
user_agent = platform.platform() + ",re6stnet/" + version.version
def __init__(self, url, cert=None, auto_close=True):
self.cert = cert
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment