Compare commits
No commits in common. "9f17500dcdfcbdce5a74df4331e66a3790a23a58" and "4ddb1d3446cb34e650fe68b2c116eff44a817ecd" have entirely different histories.
9f17500dcd
...
4ddb1d3446
6 changed files with 3 additions and 136 deletions
67
README.md
67
README.md
|
@ -1,68 +1,3 @@
|
||||||
# voipSMS
|
# voipsms
|
||||||
|
|
||||||
Python flask app that uses voip.ms to manage a number of DID numbers for SMS. Can be used to get mostly anonymous texts and sms verification.
|
Python flask app that uses voip.ms to manage a number of DID numbers for SMS. Can be used to get mostly anonymous texts and sms verification.
|
||||||
|
|
||||||
## How to use
|
|
||||||
|
|
||||||
1. Clone the repo
|
|
||||||
|
|
||||||
`git clone http://git.community.i2p/anons-voip/voipsms.git && cd voipsms`
|
|
||||||
|
|
||||||
2. Create and activate a python venv
|
|
||||||
|
|
||||||
`python3 -m venv venv && source ./venv/bin/activate`
|
|
||||||
|
|
||||||
3. Install requirements
|
|
||||||
|
|
||||||
`pip install -r requirements.txt`
|
|
||||||
|
|
||||||
4. Set your config
|
|
||||||
|
|
||||||
`vim config.json`
|
|
||||||
|
|
||||||
[Read about how to set up your config here!](./README.md#Config)
|
|
||||||
|
|
||||||
5. Start up the server
|
|
||||||
|
|
||||||
`./run`
|
|
||||||
|
|
||||||
## Config
|
|
||||||
|
|
||||||
The config used in this project uses the JSON format and expects a `username` and `password`
|
|
||||||
|
|
||||||
Ex:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"username":"voipms-email",
|
|
||||||
"password":"voipms-api-password"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Endpoints
|
|
||||||
|
|
||||||
### /numbers
|
|
||||||
|
|
||||||
*Returns a list of numbers in use*
|
|
||||||
|
|
||||||
Supports: GET
|
|
||||||
|
|
||||||
Returns a list of javascript objects with keys: did (int as string), sms_available (boolean as int), mms_available (boolean as int)
|
|
||||||
|
|
||||||
### /sms
|
|
||||||
|
|
||||||
*Returns sms/mms messages for a given number*
|
|
||||||
|
|
||||||
Supports: GET,POST
|
|
||||||
Expects: string `did`
|
|
||||||
|
|
||||||
Returns a list of javascript objects with keys: message (string), did (int as string), contact (string as int), date (date as string), media (list)
|
|
||||||
|
|
||||||
### /enablesms
|
|
||||||
|
|
||||||
*[DISABLED] Enables sms feature for a given number*
|
|
||||||
|
|
||||||
Supports: GET,POST
|
|
||||||
Expects: string `did`
|
|
||||||
|
|
||||||
Returns a boolean as int
|
|
14
app/did.py
14
app/did.py
|
@ -1,14 +0,0 @@
|
||||||
from voipms.api import Client
|
|
||||||
|
|
||||||
def get_numbers(client):
|
|
||||||
params = {
|
|
||||||
}
|
|
||||||
did_info = client.dids.fetch(params=params)
|
|
||||||
info = []
|
|
||||||
for did in did_info["dids"]:
|
|
||||||
desired_did_info = {"mms_available":None,"sms_available":None,"did":None}
|
|
||||||
for key in did:
|
|
||||||
if key in desired_did_info:
|
|
||||||
desired_did_info[key] = did[key]
|
|
||||||
info.append(desired_did_info)
|
|
||||||
return info
|
|
|
@ -1,36 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
from flask import Flask, request, abort
|
|
||||||
from voipms.api import Client
|
|
||||||
import did, sms
|
|
||||||
import json
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
with open("config.json",'r') as conf_file:
|
|
||||||
conf = json.load(conf_file)
|
|
||||||
client = Client(conf["username"],conf["password"])
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", methods=['GET'])
|
|
||||||
def default():
|
|
||||||
return '<a href="http://git.community.i2p/anons-voip/voipsms">Check out the project</a>'
|
|
||||||
|
|
||||||
@app.route("/numbers", methods=['GET'])
|
|
||||||
def get_numbers():
|
|
||||||
return did.get_numbers(client)
|
|
||||||
|
|
||||||
@app.route("/sms",methods=['GET', 'POST'])
|
|
||||||
def get_sms():
|
|
||||||
did = request.args.get('did')
|
|
||||||
return sms.get_sms(client, did)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/enablesms",methods=['GET', 'POST'])
|
|
||||||
def set_sms():
|
|
||||||
abort(403)
|
|
||||||
did = request.args.get('did')
|
|
||||||
return sms.get_sms(client, did)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
from waitress import serve
|
|
||||||
serve(app, host="0.0.0.0", port=8080)
|
|
16
app/sms.py
16
app/sms.py
|
@ -1,16 +0,0 @@
|
||||||
from voipms.api import Client
|
|
||||||
|
|
||||||
def get_sms(client, did):
|
|
||||||
params = {
|
|
||||||
"did":did,
|
|
||||||
"type":1,
|
|
||||||
"all_messages":1
|
|
||||||
}
|
|
||||||
return client.dids.sms.fetch(params=params)
|
|
||||||
|
|
||||||
def enable_sms(client, did):
|
|
||||||
params = {
|
|
||||||
"did":did,
|
|
||||||
"enable":1,
|
|
||||||
}
|
|
||||||
return client.dids.sms.set(params=params)
|
|
|
@ -1,4 +1,3 @@
|
||||||
voipms-python
|
voipms-python
|
||||||
flask
|
flask
|
||||||
waitress
|
|
||||||
requests
|
requests
|
3
run
3
run
|
@ -1,3 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#flask --app app/server run --host=0.0.0.0 --port 8080
|
flask --app app/server run --host=0.0.0.0 --port 8080
|
||||||
python3 app/server.py
|
|
||||||
|
|
Loading…
Reference in a new issue