Skip to content

Commit

Permalink
[new-git-repository] Remove IP address check for git.mysociety.org
Browse files Browse the repository at this point in the history
We can't rely on the IP address for git.mysociety.org being bound to a
local interface on the server hosting it any longer.

For now this replaces the check with one that checks for the presence of
`/data/git`, which isn't perfect but is better than nothing.

Fixes #69
  • Loading branch information
sagepe committed Jan 9, 2023
1 parent 4be6b06 commit cac2929
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions bin/new-git-repository
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ import argparse
import json
import os
import requests
import socket
from subprocess import check_call
import sys

def is_correct_server():
git_ip = socket.gethostbyname('git.mysociety.org')

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('46.43.39.78', 0)) # connecting to a UDP address doesn't send packets
local_ip = s.getsockname()[0]

if git_ip != local_ip:
if os.path.exists('/data/git'):
return
else:
sys.exit("You can only run this on git.mysociety.org")

def parse_arguments():
Expand Down

0 comments on commit cac2929

Please sign in to comment.