Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Stop allowing CORS for the JSON-RPC server
Browse files Browse the repository at this point in the history
from upstream #3659, 

spesmilo/electrum#3374
  • Loading branch information
cryptapus authored Jan 7, 2018
1 parent 5ed2cd8 commit 2ccebb1
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions lib/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import time

import jsonrpclib
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer, SimpleJSONRPCRequestHandler
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer

from version import ELECTRUM_VERSION
from network import Network
Expand Down Expand Up @@ -85,19 +85,6 @@ def get_server(config):



class RequestHandler(SimpleJSONRPCRequestHandler):

def do_OPTIONS(self):
self.send_response(200)
self.end_headers()

def end_headers(self):
self.send_header("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Allow-Origin", "*")
SimpleJSONRPCRequestHandler.end_headers(self)


class Daemon(DaemonThread):

def __init__(self, config, fd):
Expand All @@ -124,8 +111,7 @@ def init_server(self, config, fd):
host = config.get('rpchost', '127.0.0.1')
port = config.get('rpcport', 0)
try:
server = SimpleJSONRPCServer((host, port), logRequests=False,
requestHandler=RequestHandler)
server = SimpleJSONRPCServer((host, port), logRequests=False)
except:
self.print_error('Warning: cannot initialize RPC server on host', host)
self.server = None
Expand Down

0 comments on commit 2ccebb1

Please sign in to comment.