Compare commits
10 commits
4ddb1d3446
...
9f17500dcd
Author | SHA1 | Date | |
---|---|---|---|
9f17500dcd | |||
e51fd5f591 | |||
9f800b4f99 | |||
f794d5de2c | |||
e71a8101e9 | |||
f2ccc092f8 | |||
ca4b92a6bf | |||
5fc948a617 | |||
8d73e7e779 | |||
0107ed6e84 |
6 changed files with 136 additions and 3 deletions
67
README.md
67
README.md
|
@ -1,3 +1,68 @@
|
|||
# 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.
|
||||
|
||||
## 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
Normal file
14
app/did.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
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
|
36
app/server.py
Executable file
36
app/server.py
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/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
Normal file
16
app/sms.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
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,3 +1,4 @@
|
|||
voipms-python
|
||||
flask
|
||||
waitress
|
||||
requests
|
3
run
3
run
|
@ -1,2 +1,3 @@
|
|||
#!/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