Last active
February 11, 2020 00:00
-
-
Save patrickjahns/c3118bff7b77f475823e547d663f8c34 to your computer and use it in GitHub Desktop.
naz tls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
smpp_server: | |
image: komuw/smpp_server:v0.3 | |
ports: | |
- 2775:2775 | |
- 8884:8884 | |
nginx: | |
image: nginx | |
volumes: | |
- ./docker/nginx.conf:/etc/nginx/nginx.conf:ro | |
- ./docker/cert:/etc/nginx/cert:ro | |
ports: | |
- 3000:2775 | |
redis: | |
image: 'redis:5.0-alpine' | |
ports: | |
- "6379:6379" | |
rabbitmq: | |
image: rabbitmq:3.7.7-management-alpine | |
ports: | |
- 15672:15672 | |
- 5672:5672 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
├── docker | |
│ ├── cert | |
│ │ ├── nginx-selfsigned.crt | |
│ │ └── nginx-selfsigned.key | |
│ └── nginx.conf | |
├── docker-compose.yml | |
└── test.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN CERTIFICATE----- | |
MIICljCCAX4CCQCMbrYdWCbylzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJE | |
RTAeFw0yMDAyMTAyMjQ4MTVaFw0yMTAyMDkyMjQ4MTVaMA0xCzAJBgNVBAYTAkRF | |
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvO/N7mkq7wOWxAhJagoS | |
FZpEQuFaakxfPlh3oX/rBLuOlh2oQF28ygOQL8ZCZ0CuEfQwxDdSmmYHNAZYWatq | |
2RePXX/8W1I3kLf120ibwPtxbmLMLd2fv8NbrjEmZADG+Run5ZVkv7seFKqYmwMQ | |
c1+Gi7TkexMC3kY8RfpeyMwacvmngoFur5/yMIWCFleVNIc2u67lVvgmrVcDJU4U | |
4B5RoOY5b+mTFl3I1psEXC/PjUR0Uf8kB17pnMbl8zRbJ9XQ+ie4I1gg96Or37fF | |
Z5IzaBPOm53WObKH2VgT3b/AEU4EHhZB9y9raKxapy/SqbXqdDLii9TfCtem+87z | |
GQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBTMOHUa6Dda3qczmn2X/mI0H9vktCU | |
pfs1ovrXpXV4vAPQMBfMmcWLFkXMBpjIOCW4Y8DKvePt/xfAnd+DkI3/M+KP5s2h | |
+iwlfoGYpWMVp4XYUClGiG40EYU60MCqayKE0vazhDcXL4tA7ASY4vN4wpIvMAFv | |
IpEwWvhroj4Nh2W3CfYsKDZOreHIQcnKjfRyFbiwb4PgFy+RfQlVcqpJPFcQ660Y | |
uyKZHAmTlDCIKTJei6THVnADIKxhUr4dnT3z0ucO1ZBuQNs9s3HQWQZKpKek8qAV | |
M9URR/DKla0fAaR2kwYwhFZrqSTJGwupe6kHgGc+7fJKzOKOcrUQb/5z | |
-----END CERTIFICATE----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN PRIVATE KEY----- | |
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC8783uaSrvA5bE | |
CElqChIVmkRC4VpqTF8+WHehf+sEu46WHahAXbzKA5AvxkJnQK4R9DDEN1KaZgc0 | |
BlhZq2rZF49df/xbUjeQt/XbSJvA+3FuYswt3Z+/w1uuMSZkAMb5G6fllWS/ux4U | |
qpibAxBzX4aLtOR7EwLeRjxF+l7IzBpy+aeCgW6vn/IwhYIWV5U0hza7ruVW+Cat | |
VwMlThTgHlGg5jlv6ZMWXcjWmwRcL8+NRHRR/yQHXumcxuXzNFsn1dD6J7gjWCD3 | |
o6vft8VnkjNoE86bndY5sofZWBPdv8AR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Tqphd6ElKyhi6kGzgCUV3u1tFz | |
uuk+uGOiK4jcp2JVhVpa0H1stLbRqArdN6mSTjVtAoGBAJi13Mb3zw81DVn7EGch | |
53Ypbyj8pscc80z8KML0HE2Ec05klWNJ8KLp5l3nTczRt1feoy3lW3K3fMlqJkmu | |
jn4xELWCkpCYkMuHP+cSsdYPncRLmtdYcrCTjQ4H6GyioW0hyKeGzu3Zyjeo7ioj | |
wVEdY66jULBkVwwtXJ+4W2Cb | |
-----END PRIVATE KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events { } | |
stream { | |
log_format basic '$remote_addr [$time_local] ' | |
'$protocol $status $bytes_sent $bytes_received ' | |
'$session_time'; | |
server { | |
listen 2775 ssl; | |
ssl_certificate /etc/nginx/cert/nginx-selfsigned.crt; | |
ssl_certificate_key /etc/nginx/cert/nginx-selfsigned.key; | |
proxy_ssl off; | |
proxy_pass smpp_server:2775; | |
access_log /dev/stdout basic; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import asyncio | |
from time import time | |
import naz | |
import ssl | |
loop = asyncio.get_event_loop() | |
broker = naz.broker.SimpleBroker(maxsize=1000) | |
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,) | |
ssl_context.check_hostname = False | |
ssl_context.load_verify_locations("./docker/cert/nginx-selfsigned.crt") | |
cli = naz.Client( | |
smsc_host="localhost", | |
smsc_port=3000, | |
system_id="smppclient1", | |
password=os.getenv("password", "password"), | |
broker=broker, | |
socket_timeout=10.0, | |
ssl_context=ssl_context, | |
) | |
# queue messages to send | |
for i in range(0, 10): | |
print("submit_sm round:", i) | |
loop.run_until_complete( | |
broker.enqueue( | |
naz.protocol.SubmitSM( | |
short_message="Hello World-{0}".format(str(i)), | |
log_id="myid1234-{0}".format(str(i)), | |
source_addr="254722111111", | |
destination_addr="254722999999", | |
) | |
) | |
) | |
try: | |
# 1. connect to the SMSC host | |
# 2. bind to the SMSC host | |
# 3. send any queued messages to SMSC | |
# 4. read any data from SMSC | |
# 5. continually check the state of the SMSC | |
tasks = asyncio.gather( | |
cli.connect(), | |
cli.tranceiver_bind(), | |
cli.dequeue_messages(), | |
cli.receive_data(), | |
cli.enquire_link(), | |
) | |
loop.run_until_complete(tasks) | |
except Exception as e: | |
print("\n\t error occured. error={0}".format(str(e))) | |
finally: | |
loop.run_until_complete(cli.unbind()) | |
loop.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment