mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
8aad4a16b3
Some checks are pending
Sync test / sync-test-windows-debug-asan (push) Waiting to run
Sync test / sync-test-windows-leaks (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:aarch64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline -mfix-cortex-a53-835769 -mfix-cortex-a53-843419]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:riscv64 branch:edge flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:x86_64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-11 cpp:g++-11 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-12 cpp:g++-12 flags: os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-8 cpp:g++-8 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-static-libs (map[flags:-fuse-linker-plugin -ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:clang cxx:clang++ flags:-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:gcc cxx:g++ flags:-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:OFF upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2022 rx:ON tls:ON upnp:ON vs:Visual Studio 17 2022 vspath:C:\Program Files\Microsoft Visual Studio\2022\Enterprise]) (push) Waiting to run
C/C++ CI / build-macos (push) Waiting to run
C/C++ CI / build-macos-aarch64 (push) Waiting to run
C/C++ CI / build-freebsd (map[architecture:x86-64 host:ubuntu-latest name:freebsd version:13.3]) (push) Waiting to run
C/C++ CI / build-openbsd (map[architecture:x86-64 host:ubuntu-latest name:openbsd version:7.4]) (push) Waiting to run
clang-tidy / clang-tidy (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
cppcheck / cppcheck-ubuntu (push) Waiting to run
cppcheck / cppcheck-windows (push) Waiting to run
Microsoft C++ Code Analysis / Analyze (push) Waiting to run
source-snapshot / source-snapshot (push) Waiting to run
Sync test (old) / sync-test-ubuntu-tsan (push) Waiting to run
Sync test (old) / sync-test-ubuntu-msan (push) Waiting to run
Sync test (old) / sync-test-ubuntu-ubsan (push) Waiting to run
Sync test (old) / sync-test-ubuntu-asan (push) Waiting to run
Sync test (old) / sync-test-macos (map[flags:-Og -ftrapv -target arm64-apple-macos-11 os:macos-14]) (push) Waiting to run
Sync test (old) / sync-test-macos (map[flags:-Og -ftrapv os:macos-13]) (push) Waiting to run
Sync test (old) / sync-test-windows-debug-asan (push) Waiting to run
Sync test (old) / sync-test-windows-leaks (push) Waiting to run
Sync test / sync-test-ubuntu-tsan (push) Waiting to run
Sync test / sync-test-ubuntu-msan (push) Waiting to run
Sync test / sync-test-ubuntu-ubsan (push) Waiting to run
Sync test / sync-test-ubuntu-asan (push) Waiting to run
Sync test / sync-test-macos (map[flags:-Og -ftrapv -target arm64-apple-macos-11 os:macos-14]) (push) Waiting to run
Sync test / sync-test-macos (map[flags:-Og -ftrapv os:macos-13]) (push) Waiting to run
122 lines
3 KiB
Python
122 lines
3 KiB
Python
# This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
|
# Copyright (c) 2021-2024 SChernykh <https://github.com/SChernykh>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, version 3.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import socket
|
|
import time
|
|
import sys
|
|
import json
|
|
import ssl
|
|
|
|
f = open('stratum_dummy' + sys.argv[1] + '.log', 'wb')
|
|
|
|
f.write(b'Connecting')
|
|
f.flush()
|
|
|
|
context = ssl.create_default_context()
|
|
context.check_hostname = False
|
|
context.verify_mode = ssl.CERT_NONE
|
|
|
|
while True:
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.settimeout(1)
|
|
sock.setblocking(True)
|
|
|
|
if (sys.argv[1] == '1'):
|
|
sock = context.wrap_socket(sock);
|
|
|
|
if sock.connect_ex(('127.0.0.1', 3333)) == 0:
|
|
break;
|
|
|
|
sock.close()
|
|
|
|
f.write(b'.')
|
|
f.flush()
|
|
print('.')
|
|
time.sleep(1)
|
|
|
|
f.write(b'\n')
|
|
f.flush()
|
|
|
|
diff = ''
|
|
|
|
if (sys.argv[1] == '2'):
|
|
diff = '+1000'
|
|
if (sys.argv[1] == '3'):
|
|
diff = '+10000000'
|
|
|
|
msg_id = 1
|
|
|
|
request = '{"id":' + str(msg_id) + ',"method":"login","params":{"login":"x' + diff + '"}}\n'
|
|
msg_id += 1
|
|
s = '-> ' + request
|
|
print(s, end='')
|
|
sock.sendall(request.encode('utf-8'))
|
|
|
|
f.write(s.encode('utf-8'))
|
|
f.flush()
|
|
|
|
rpc_id = ''
|
|
|
|
while True:
|
|
data = sock.recv(1024)
|
|
if len(data) == 0:
|
|
break
|
|
|
|
s = '<- ' + data.decode('utf-8')
|
|
print(s, end='')
|
|
|
|
f.write(s.encode('utf-8'))
|
|
f.flush()
|
|
|
|
obj = json.loads(data)
|
|
job_id = ''
|
|
|
|
if ('method' in obj) and ('params' in obj) and (obj['method'] == 'job'):
|
|
job_id = obj['params']['job_id']
|
|
target = obj['params']['target']
|
|
elif ('result' in obj) and ('job' in obj['result']):
|
|
if ('id' in obj['result']):
|
|
rpc_id = obj['result']['id']
|
|
job_id = obj['result']['job']['job_id']
|
|
target = obj['result']['job']['target']
|
|
|
|
if (job_id != ''):
|
|
if (msg_id < 4):
|
|
result = ('f' if (msg_id == 2) else '0') * 64
|
|
request = '{"id":' + str(msg_id) + ',"method":"submit","params":{"id":"' + rpc_id + '","job_id":"' + job_id + '","nonce":"ffffffff","result":"' + result + '"}}\n'
|
|
elif (msg_id == 4):
|
|
request = '{"id":' + str(msg_id) + ',"method":"keepalived"}\n'
|
|
else:
|
|
t = bytearray.fromhex(target)
|
|
for i in range(len(t)):
|
|
if (t[i] > 0):
|
|
t[i] -= 1
|
|
break
|
|
else:
|
|
t[i] = 255
|
|
|
|
result = ('f' * (64 - len(target))) + t.hex()
|
|
request = '{"id":' + str(msg_id) + ',"method":"submit","params":{"id":"' + rpc_id + '","job_id":"' + job_id + '","nonce":"ffffffff","result":"' + result + '"}}\n'
|
|
|
|
msg_id += 1
|
|
s = '-> ' + request
|
|
print(s, end='')
|
|
sock.sendall(request.encode('utf-8'))
|
|
|
|
f.write(s.encode('utf-8'))
|
|
f.flush()
|
|
|
|
sock.close()
|
|
f.close()
|