29 lines
711 B
D
29 lines
711 B
D
import std.stdio;
|
|
import std.socket;
|
|
import std.date;
|
|
import std.string;
|
|
import std.md5;
|
|
|
|
|
|
void main() {
|
|
const char[] DYN_ID = "test";
|
|
const char[] SHARED_SECRET = "geheim";
|
|
|
|
const char[] SERVER_IP = "172.16.2.1";
|
|
const int SERVER_PORT = 8053;
|
|
|
|
|
|
long time = getUTCtime() / TicksPerSecond;
|
|
char[] data = format("%s %s %d", DYN_ID, SHARED_SECRET, time);
|
|
|
|
ubyte[16] checksum;
|
|
sum(checksum, data);
|
|
|
|
char[] dataToSend = format("%s %d %s", DYN_ID, time, tolower(digestToString(checksum)));
|
|
|
|
Socket sock = new UdpSocket(AddressFamily.INET);
|
|
InternetAddress serverAddress = new InternetAddress(SERVER_IP, SERVER_PORT);
|
|
sock.sendTo(dataToSend, serverAddress);
|
|
sock.close();
|
|
}
|