Initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
126
client.js
Normal file
126
client.js
Normal file
@@ -0,0 +1,126 @@
|
||||
const smpp = require("smpp");
|
||||
const commandLineArgs = require("command-line-args");
|
||||
const commandLineUsage = require("command-line-usage");
|
||||
|
||||
const optionDefinitions = [
|
||||
{ name: "help", type: String, description: "Display this usage guide." },
|
||||
{ name: "host", alias: "h", type: String, description: "The host (IP) to connect to." },
|
||||
{ name: "port", alias: "p", type: Number, description: "The port to connect to." },
|
||||
{ name: "systemId", alias: "s", type: String, description: "SMPP related login info." },
|
||||
{ name: "password", alias: "pa", type: String, description: "SMPP related login info." },
|
||||
{
|
||||
name: "messageCount",
|
||||
alias: "mc",
|
||||
type: Number,
|
||||
description: "Number of messages to send; Optional, defaults to 1.",
|
||||
},
|
||||
{
|
||||
name: "source",
|
||||
alias: "src",
|
||||
type: String,
|
||||
description: "Source field of the sent messages.",
|
||||
defaultOption: "smppDebugClient",
|
||||
},
|
||||
{
|
||||
name: "destination",
|
||||
alias: "dst",
|
||||
type: String,
|
||||
description: "Destination field of the sent messages.",
|
||||
defaultOption: "smpp",
|
||||
},
|
||||
{
|
||||
name: "message",
|
||||
alias: "msg",
|
||||
type: String,
|
||||
description: "Text content of the sent messages.",
|
||||
defaultOption: "smpp debug message",
|
||||
},
|
||||
{ name: "debug", type: Boolean, description: "Display all traffic to and from the client; Debug mode." },
|
||||
];
|
||||
|
||||
const options = commandLineArgs(optionDefinitions);
|
||||
|
||||
if (options.help) {
|
||||
const usage = commandLineUsage([
|
||||
{
|
||||
header: "CLI SMPP (Client)",
|
||||
}, {
|
||||
header: "Options",
|
||||
optionList: optionDefinitions
|
||||
},
|
||||
{
|
||||
content: "Project home: {underline }"
|
||||
}
|
||||
]);
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
host = String(host);
|
||||
port = Number(port);
|
||||
systemId = String(systemId);
|
||||
password = String(password);
|
||||
messageCount = Number(messageCount) || 1;
|
||||
source = source || "smppClientDebug";
|
||||
destination = destination || "smpp";
|
||||
message = message || "smpp debug message";
|
||||
} catch (e) {
|
||||
console.log(`Invalid params: ˘${e}`);
|
||||
console.log(`Usage: client <host> <port> <systemId> <password> <messageCount?> <source?> <destination?> <message?>
|
||||
If not provided:
|
||||
messageCount defaults to 1 (value of 0 is permitted)
|
||||
source defaults to smppClientDebug
|
||||
destination defaults to smpp
|
||||
message defaults to "smpp debug message"
|
||||
Note:
|
||||
Host is in the form of IP
|
||||
Port must be a number
|
||||
MessageCount must be a number
|
||||
`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let message_id = 0;
|
||||
console.log(`Connecting to ${host}:${port}...`);
|
||||
const session = smpp.connect(
|
||||
{
|
||||
url: `smpp://${host}:${port}`,
|
||||
auto_enquire_link_period: 10000,
|
||||
debug: false,
|
||||
},
|
||||
function () {
|
||||
console.log("Connected, sending bind_transciever...");
|
||||
session.bind_transceiver(
|
||||
{
|
||||
system_id: systemId,
|
||||
password: password,
|
||||
},
|
||||
function (pdu) {
|
||||
if (pdu.command_status === 0) {
|
||||
// Successfully bound
|
||||
console.log("sending shit");
|
||||
session.submit_sm(
|
||||
{
|
||||
source_addr: "smpp_test_1",
|
||||
destination_addr: "123123123123",
|
||||
short_message: "Hello!",
|
||||
data_coding: 0xc0,
|
||||
},
|
||||
function (pdu) {
|
||||
if (pdu.command_status === 0) {
|
||||
console.log(pdu.message_id);
|
||||
message_id = pdu.message_id;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
session.on("deliver_sm", function (pdu) {
|
||||
console.log("Got deliver_sm");
|
||||
session.send(pdu.response());
|
||||
});
|
11
package.json
11
package.json
@@ -2,11 +2,16 @@
|
||||
"name": "smpp",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"dev": "node main.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"command-line-args": "^5.2.1",
|
||||
"command-line-usage": "^7.0.1",
|
||||
"smpp": "0.6.0-rc.4"
|
||||
}
|
||||
}
|
||||
|
181
pnpm-lock.yaml
generated
Normal file
181
pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,181 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
command-line-args:
|
||||
specifier: ^5.2.1
|
||||
version: 5.2.1
|
||||
command-line-usage:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1
|
||||
smpp:
|
||||
specifier: 0.6.0-rc.4
|
||||
version: 0.6.0-rc.4
|
||||
|
||||
packages:
|
||||
|
||||
/@75lb/deep-merge@1.1.1:
|
||||
resolution: {integrity: sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==}
|
||||
engines: {node: '>=12.17'}
|
||||
dependencies:
|
||||
lodash.assignwith: 4.2.0
|
||||
typical: 7.1.1
|
||||
dev: false
|
||||
|
||||
/ansi-styles@4.3.0:
|
||||
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
color-convert: 2.0.1
|
||||
dev: false
|
||||
|
||||
/array-back@3.1.0:
|
||||
resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==}
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/array-back@6.2.2:
|
||||
resolution: {integrity: sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==}
|
||||
engines: {node: '>=12.17'}
|
||||
dev: false
|
||||
|
||||
/chalk-template@0.4.0:
|
||||
resolution: {integrity: sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
chalk: 4.1.2
|
||||
dev: false
|
||||
|
||||
/chalk@4.1.2:
|
||||
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||
engines: {node: '>=10'}
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
supports-color: 7.2.0
|
||||
dev: false
|
||||
|
||||
/color-convert@2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
dev: false
|
||||
|
||||
/color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
dev: false
|
||||
|
||||
/command-line-args@5.2.1:
|
||||
resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
dependencies:
|
||||
array-back: 3.1.0
|
||||
find-replace: 3.0.0
|
||||
lodash.camelcase: 4.3.0
|
||||
typical: 4.0.0
|
||||
dev: false
|
||||
|
||||
/command-line-usage@7.0.1:
|
||||
resolution: {integrity: sha512-NCyznE//MuTjwi3y84QVUGEOT+P5oto1e1Pk/jFPVdPPfsG03qpTIl3yw6etR+v73d0lXsoojRpvbru2sqePxQ==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
dependencies:
|
||||
array-back: 6.2.2
|
||||
chalk-template: 0.4.0
|
||||
table-layout: 3.0.2
|
||||
typical: 7.1.1
|
||||
dev: false
|
||||
|
||||
/find-replace@3.0.0:
|
||||
resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
dependencies:
|
||||
array-back: 3.1.0
|
||||
dev: false
|
||||
|
||||
/findhit-proxywrap@0.3.13:
|
||||
resolution: {integrity: sha512-gI1KV7yCuMHtveiWbQUJZheNOukScz+15MTtrH/MK5RJ77JjYeJ1DegUfkBnlPvDx5NhZESl48zE/MwpWZ1LXQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
dependencies:
|
||||
lodash: 4.17.21
|
||||
dev: false
|
||||
|
||||
/has-flag@4.0.0:
|
||||
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/iconv-lite@0.6.3:
|
||||
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dependencies:
|
||||
safer-buffer: 2.1.2
|
||||
dev: false
|
||||
|
||||
/lodash.assignwith@4.2.0:
|
||||
resolution: {integrity: sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==}
|
||||
dev: false
|
||||
|
||||
/lodash.camelcase@4.3.0:
|
||||
resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==}
|
||||
dev: false
|
||||
|
||||
/lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
dev: false
|
||||
|
||||
/safer-buffer@2.1.2:
|
||||
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
|
||||
dev: false
|
||||
|
||||
/smpp@0.6.0-rc.4:
|
||||
resolution: {integrity: sha512-WDa0XBRQkkJJPcKRtoC9C0cnzhopFIK9/zFcWBOy3sD4xZr3i/Dt3yX+XRparKzpp9QkqRr2/8EYt8JNGxu85w==}
|
||||
engines: {node: '>=4'}
|
||||
dependencies:
|
||||
findhit-proxywrap: 0.3.13
|
||||
iconv-lite: 0.6.3
|
||||
safer-buffer: 2.1.2
|
||||
dev: false
|
||||
|
||||
/stream-read-all@3.0.1:
|
||||
resolution: {integrity: sha512-EWZT9XOceBPlVJRrYcykW8jyRSZYbkb/0ZK36uLEmoWVO5gxBOnntNTseNzfREsqxqdfEGQrD8SXQ3QWbBmq8A==}
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/supports-color@7.2.0:
|
||||
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
has-flag: 4.0.0
|
||||
dev: false
|
||||
|
||||
/table-layout@3.0.2:
|
||||
resolution: {integrity: sha512-rpyNZYRw+/C+dYkcQ3Pr+rLxW4CfHpXjPDnG7lYhdRoUcZTUt+KEsX+94RGp/aVp/MQU35JCITv2T/beY4m+hw==}
|
||||
engines: {node: '>=12.17'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@75lb/deep-merge': 1.1.1
|
||||
array-back: 6.2.2
|
||||
command-line-args: 5.2.1
|
||||
command-line-usage: 7.0.1
|
||||
stream-read-all: 3.0.1
|
||||
typical: 7.1.1
|
||||
wordwrapjs: 5.1.0
|
||||
dev: false
|
||||
|
||||
/typical@4.0.0:
|
||||
resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/typical@7.1.1:
|
||||
resolution: {integrity: sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==}
|
||||
engines: {node: '>=12.17'}
|
||||
dev: false
|
||||
|
||||
/wordwrapjs@5.1.0:
|
||||
resolution: {integrity: sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg==}
|
||||
engines: {node: '>=12.17'}
|
||||
dev: false
|
Reference in New Issue
Block a user