Compare commits
10 Commits
lash/brows
...
lash/trans
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
910d9ce5b1 | ||
|
|
6485f57045
|
||
|
|
ceafea7930
|
||
|
|
906c7f17d0
|
||
|
|
77f6eb193c
|
||
|
|
195b1e3c9b
|
||
|
|
951ba52de4
|
||
|
|
5b3e72b0b7 | ||
|
|
5f5687e9fe
|
||
|
|
7549c6ff97
|
@@ -10,7 +10,7 @@ version = (
|
|||||||
0,
|
0,
|
||||||
10,
|
10,
|
||||||
0,
|
0,
|
||||||
'alpha.39',
|
'alpha.38',
|
||||||
)
|
)
|
||||||
|
|
||||||
version_object = semver.VersionInfo(
|
version_object = semver.VersionInfo(
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
[app]
|
|
||||||
service_code = *483*46#
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
[client]
|
|
||||||
host =
|
|
||||||
port =
|
|
||||||
ssl =
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[ussd]
|
|
||||||
user =
|
|
||||||
pass =
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
|
|
||||||
# Author: Louis Holbrook <dev@holbrook.no> (https://holbrook.no)
|
|
||||||
# Description: interactive console for Sempo USSD session
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
# standard imports
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import uuid
|
|
||||||
import json
|
|
||||||
import argparse
|
|
||||||
import logging
|
|
||||||
import urllib
|
|
||||||
from xdg.BaseDirectory import xdg_config_home
|
|
||||||
from urllib import request
|
|
||||||
|
|
||||||
# third-party imports
|
|
||||||
from confini import Config
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
|
||||||
logg = logging.getLogger()
|
|
||||||
|
|
||||||
config_dir = os.path.join(xdg_config_home, 'cli-ussd')
|
|
||||||
|
|
||||||
argparser = argparse.ArgumentParser(description='CLI tool to interface a Sempo USSD session')
|
|
||||||
argparser.add_argument('-c', type=str, default=config_dir, help='config root to use')
|
|
||||||
#argparser.add_argument('-d', type=str, default='local', help='deployment name to interface (config root subdirectory)')
|
|
||||||
argparser.add_argument('--host', type=str, default='localhost')
|
|
||||||
argparser.add_argument('--port', type=int, default=9000)
|
|
||||||
argparser.add_argument('--nossl', help='do not use ssl (careful)', action='store_true')
|
|
||||||
argparser.add_argument('phone', help='phone number for USSD session')
|
|
||||||
argparser.add_argument('-v', help='be verbose', action='store_true')
|
|
||||||
argparser.add_argument('-vv', help='be more verbose', action='store_true')
|
|
||||||
|
|
||||||
args = argparser.parse_args(sys.argv[1:])
|
|
||||||
|
|
||||||
if args.v == True:
|
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
|
||||||
elif args.vv == True:
|
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
|
||||||
|
|
||||||
#config_dir = os.path.join(args.c, args.d)
|
|
||||||
config_dir = os.path.join(args.c)
|
|
||||||
os.makedirs(config_dir, 0o777, True)
|
|
||||||
|
|
||||||
config = Config(config_dir)
|
|
||||||
config.process()
|
|
||||||
logg.debug('config loaded from {}'.format(config_dir))
|
|
||||||
|
|
||||||
host = config.get('CLIENT_HOST')
|
|
||||||
port = config.get('CLIENT_PORT')
|
|
||||||
ssl = config.get('CLIENT_SSL')
|
|
||||||
|
|
||||||
if host == None:
|
|
||||||
host = args.host
|
|
||||||
if port == None:
|
|
||||||
port = args.port
|
|
||||||
if ssl == None:
|
|
||||||
ssl = not args.nossl
|
|
||||||
elif ssl == 0:
|
|
||||||
ssl = False
|
|
||||||
else:
|
|
||||||
ssl = True
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
# TODO: improve url building
|
|
||||||
url = 'http'
|
|
||||||
if ssl:
|
|
||||||
url += 's'
|
|
||||||
url += '://{}:{}'.format(host, port)
|
|
||||||
url += '/?username={}&password={}'.format(config.get('USSD_USER'), config.get('USSD_PASS'))
|
|
||||||
|
|
||||||
logg.info('service url {}'.format(url))
|
|
||||||
logg.info('phone {}'.format(args.phone))
|
|
||||||
|
|
||||||
session = uuid.uuid4().hex
|
|
||||||
data = {
|
|
||||||
'sessionId': session,
|
|
||||||
'serviceCode': config.get('APP_SERVICE_CODE'),
|
|
||||||
'phoneNumber': args.phone,
|
|
||||||
'text': config.get('APP_SERVICE_CODE'),
|
|
||||||
}
|
|
||||||
|
|
||||||
state = "_BEGIN"
|
|
||||||
while state != "END":
|
|
||||||
|
|
||||||
if state != "_BEGIN":
|
|
||||||
user_input = input('next> ')
|
|
||||||
data['text'] = user_input
|
|
||||||
|
|
||||||
req = urllib.request.Request(url)
|
|
||||||
data_str = json.dumps(data)
|
|
||||||
data_bytes = data_str.encode('utf-8')
|
|
||||||
req.add_header('Content-Type', 'application/json')
|
|
||||||
req.data = data_bytes
|
|
||||||
response = urllib.request.urlopen(req)
|
|
||||||
response_data = response.read().decode('utf-8')
|
|
||||||
state = response_data[:3]
|
|
||||||
out = response_data[4:]
|
|
||||||
print(out)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
import semver
|
import semver
|
||||||
|
|
||||||
version = (0, 3, 0, 'alpha.2')
|
version = (0, 3, 0, 'alpha.1')
|
||||||
|
|
||||||
version_object = semver.VersionInfo(
|
version_object = semver.VersionInfo(
|
||||||
major=version[0],
|
major=version[0],
|
||||||
|
|||||||
@@ -16,16 +16,9 @@ div#session {
|
|||||||
<textarea id="monitor" disabled="1"></textarea>
|
<textarea id="monitor" disabled="1"></textarea>
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<label for="user">API username</label>
|
<label for="user">API username</label>
|
||||||
<input type="text" id="user" name="user" />
|
<input type="text" id="user" name="user" type="text" /><br/>
|
||||||
<label for="user">API password</label>
|
<label for="user">API password</label>
|
||||||
<input type="text" id="pass" name="pass" /> <br/>
|
<input type="text" id="pass" name="pass" type="text" /><br/>
|
||||||
|
|
||||||
<label for="host">API host</label>
|
|
||||||
<input type="text" id="host" name="host" />
|
|
||||||
<label for="host">API port</label>
|
|
||||||
<input type="text" id="port" name="port" />
|
|
||||||
<label for="host">SSL</label>
|
|
||||||
<input type="checkbox" id="ssl" name="ssl" checked="1"/> <br/>
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<input type="text" id="phone" /> <button onclick="setPhone(document.getElementById('phone').value);" id="send_phone">set phone number</button>
|
<input type="text" id="phone" /> <button onclick="setPhone(document.getElementById('phone').value);" id="send_phone">set phone number</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
var ssl = false;
|
//var proto = 'http';
|
||||||
var host = 'localhost';
|
//var host = 'localhost:9000';
|
||||||
var port = 9000;
|
|
||||||
var proto = 'https';
|
var proto = 'https';
|
||||||
var host = 'staging.sarafu.network';
|
var host = 'staging.sarafu.network';
|
||||||
var user = 'foo';
|
var user = 'admin_bert_token_inc.';
|
||||||
var pass = 'bar';
|
var pass = '197781ed60bf16d5dc12d84e3df37e35';
|
||||||
var path = '/';
|
var serviceCode = '*483*061#';
|
||||||
var serviceCode = '*483*46#';
|
|
||||||
|
|
||||||
// cheekily stolen from https://www.tutorialspoint.com/how-to-create-guid-uuid-in-javascript
|
// cheekily stolen from https://www.tutorialspoint.com/how-to-create-guid-uuid-in-javascript
|
||||||
function createUUID() {
|
function createUUID() {
|
||||||
@@ -25,17 +23,9 @@ function send(s) {
|
|||||||
document.getElementById('send_input').disabled = true;
|
document.getElementById('send_input').disabled = true;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'text';
|
xhr.responseType = 'text';
|
||||||
const current_user = document.getElementById('user').value;
|
current_user = document.getElementById('user').value;
|
||||||
const current_pass = document.getElementById('pass').value;
|
current_pass = document.getElementById('pass').value;
|
||||||
const current_host = document.getElementById('host').value;
|
xhr.open('POST', proto + '://' + host + '/api/v1/ussd/kenya?username=' + current_user + '&password=' + current_pass, true);
|
||||||
const current_port = document.getElementById('port').value;
|
|
||||||
let current_scheme = 'http';
|
|
||||||
if (document.getElementById('ssl').checked) {
|
|
||||||
current_scheme += 's';
|
|
||||||
}
|
|
||||||
const url = current_scheme + '://' + current_host + ':' + current_port + '?username=' + current_user + '&password=' + current_pass
|
|
||||||
console.debug('connecting to', url);
|
|
||||||
xhr.open('POST', url, true);
|
|
||||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||||
data = {
|
data = {
|
||||||
sessionId: uuid,
|
sessionId: uuid,
|
||||||
@@ -116,8 +106,6 @@ function abort() {
|
|||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
document.getElementById('user').value = user;
|
document.getElementById('user').value = user;
|
||||||
document.getElementById('pass').value = pass;
|
document.getElementById('pass').value = pass;
|
||||||
document.getElementById('host').value = host;
|
|
||||||
document.getElementById('port').value = port;
|
|
||||||
document.getElementById('phone').addEventListener('keyup', (e) => {
|
document.getElementById('phone').addEventListener('keyup', (e) => {
|
||||||
if (e.keyCode == '13') {
|
if (e.keyCode == '13') {
|
||||||
document.getElementById('input').value = '';
|
document.getElementById('input').value = '';
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ billiard==3.6.3.0
|
|||||||
celery==4.4.7
|
celery==4.4.7
|
||||||
cffi==1.14.3
|
cffi==1.14.3
|
||||||
chainlib~=0.0.1a15
|
chainlib~=0.0.1a15
|
||||||
cic-eth==0.10.0a39
|
cic-eth==0.10.0a38
|
||||||
cic-notify~=0.4.0a2
|
cic-notify==0.3.1
|
||||||
cic-types==0.1.0a8
|
cic-types==0.1.0a8
|
||||||
click==7.1.2
|
click==7.1.2
|
||||||
confini~=0.3.6rc3
|
confini==0.3.5
|
||||||
cryptography==3.2.1
|
cryptography==3.2.1
|
||||||
faker==4.17.1
|
faker==4.17.1
|
||||||
iniconfig==1.1.1
|
iniconfig==1.1.1
|
||||||
|
|||||||
@@ -44,5 +44,4 @@ scripts =
|
|||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
cic-ussd-tasker = cic_ussd.runnable.tasker:main
|
cic-ussd-tasker = cic_ussd.runnable.tasker:main
|
||||||
cic-ussd-client = cic_ussd.runnable.client:main
|
|
||||||
@@ -74,7 +74,7 @@ new cic.PGPKeyStore(
|
|||||||
importMeta,
|
importMeta,
|
||||||
);
|
);
|
||||||
|
|
||||||
const batchSize = 16;
|
const batchSize = 50;
|
||||||
const batchDelay = 1000;
|
const batchDelay = 1000;
|
||||||
const total = parseInt(process.argv[3]);
|
const total = parseInt(process.argv[3]);
|
||||||
const workDir = path.join(process.argv[2], 'meta');
|
const workDir = path.join(process.argv[2], 'meta');
|
||||||
|
|||||||
Reference in New Issue
Block a user