Skip to content

Commit 34843bf

Browse files
committed
power smash ppp server. iptables rules for culdcept2 and power smash
pppd server for power smash on port 7656 (PAP authentication, disable LCP echo) iptables DNAT wildcard for most iwango servers and Power Smash.
1 parent de26963 commit 34843bf

7 files changed

Lines changed: 399 additions & 14 deletions

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ clean:
4545

4646
createservice:
4747
cp pppd.socket pppd@.service ethtap.service discoping.service iptables-dcnet.service /usr/lib/systemd/system/
48+
cp psmash-pppd.socket psmash-pppd@.service /usr/lib/systemd/system/
4849
sed -i -e "s:/usr/local/sbin/:$(sbindir)/:g" /usr/lib/systemd/system/discoping.service
4950
sed -i -e "s:/usr/local/sbin/:$(sbindir)/:g" /usr/lib/systemd/system/ethtap.service
5051
sed -i -e "s:/usr/local/sbin/:$(sbindir)/:g" /usr/lib/systemd/system/iptables-dcnet.service
@@ -56,8 +57,10 @@ createservice:
5657
systemctl restart discoping.service
5758
systemctl enable iptables-dcnet.service
5859
systemctl restart iptables-dcnet.service
60+
systemctl enable psmash-pppd.socket
61+
systemctl restart psmash-pppd.socket
5962

6063
archive:
6164
tar cvzf dcnet-ap.tar.gz Makefile ppp-ipaddr.c ethtap.cpp discoping.c dcnetbba.cpp \
6265
pppd.socket pppd@.service ethtap.service dnsmasq-ethtap.conf options.dcnet discoping.service \
63-
accesspoints iptables-dcnet.service iptables-dcnet
66+
accesspoints iptables-dcnet.service iptables-dcnet psmash-pppd.socket psmash-pppd@.service options.psmash

accesspoints

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dcnet.flyca.st "US Central"
22
dcnet-eu.flyca.st Europe
3+
hmnetbrasil.duckdns.org "South America"

discoping.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <netdb.h>
2929
#include <ctype.h>
3030
#include <poll.h>
31+
#include <time.h>
3132

3233
const uint32_t MAGIC = 0xDC15C001;
3334
#define PING 1
@@ -58,6 +59,15 @@ void error(const char *str)
5859
exit(1);
5960
}
6061

62+
static const char *getDate()
63+
{
64+
time_t now;
65+
time(&now);
66+
char *nowstr = ctime(&now);
67+
nowstr[strlen(nowstr) - 1] = '\0';
68+
return nowstr;
69+
}
70+
6171
void pong(struct sockaddr_in *addr, const uint8_t *data, size_t len)
6272
{
6373
uint8_t resp[13];
@@ -82,11 +92,11 @@ uint32_t resolve(const char *servname)
8292
struct addrinfo *result;
8393
int rc = getaddrinfo(servname, NULL, &hints, &result);
8494
if (rc != 0) {
85-
fprintf(stderr, "%s: DNS failure: %s\n", servname, gai_strerror(rc));
95+
fprintf(stderr, "[%s] %s: DNS failure: %s\n", getDate(), servname, gai_strerror(rc));
8696
return 0;
8797
}
8898
if (result == NULL) {
89-
fprintf(stderr, "%s: DNS failure: no record found\n", servname);
99+
fprintf(stderr, "[%s] %s: DNS failure: no record found\n", getDate(), servname);
90100
return 0;
91101
}
92102
char ip[INET_ADDRSTRLEN];
@@ -238,7 +248,7 @@ int pingAccessPoints(int sockfd, int force)
238248
if (ap->pingCount == 5)
239249
{
240250
if (ap->offline == 0)
241-
fprintf(stderr, "Access point \"%s\" is offline\n", ap->name);
251+
fprintf(stderr, "[%s] Access point \"%s\" is offline\n", getDate(), ap->name);
242252
ap->offline = 1;
243253
continue;
244254
}
@@ -276,7 +286,7 @@ void apPong(struct sockaddr_in *addr, const uint8_t *data, size_t len)
276286
ap->lastPing = 0;
277287
ap->pingCount = 0;
278288
if (ap->offline == 1)
279-
fprintf(stderr, "Access point \"%s\" is back online\n", ap->name);
289+
fprintf(stderr, "[%s] Access point \"%s\" is back online\n", getDate(), ap->name);
280290
ap->offline = 0;
281291
return;
282292
}
@@ -303,7 +313,7 @@ int main(int argc, char *argv[])
303313
if (argc > 2)
304314
accessPointsFile = argv[2];
305315
}
306-
printf("Started discoping on port %d with list %s\n", port, accessPointsFile);
316+
printf("[%s] Started discoping on port %d with list %s\n", getDate(), port, accessPointsFile);
307317
refresh();
308318
sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
309319
if (sockfd < 0)

iptables-dcnet

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ if ! iptables -t nat -F DCNET_PRERT 2>/dev/null; then
3838
fi
3939
# Internet Game Pack
4040
iptables -t nat -A DCNET_PRERT -d 204.210.43.239/32 -p tcp -j DNAT --to-destination 172.20.0.1
41-
# Daytona USA (JP), Golf Shiyou Yo 2
42-
iptables -t nat -A DCNET_PRERT -d 203.179.41.127/32 -p tcp -j DNAT --to-destination 172.20.0.1
43-
# Sega Tetris
44-
iptables -t nat -A DCNET_PRERT -d 203.179.41.98/32 -p tcp -j DNAT --to-destination 172.20.0.1
45-
# Aero Dancing
46-
iptables -t nat -A DCNET_PRERT -d 203.179.41.170/32 -p tcp -j DNAT --to-destination 172.20.0.1
47-
# Hundred Swords
48-
iptables -t nat -A DCNET_PRERT -d 203.179.41.126/32 -p tcp -j DNAT --to-destination 172.20.0.1
41+
# IWANGO games
42+
iptables -t nat -A DCNET_PRERT -d 203.179.41.0/24 -p tcp -j DNAT --to-destination 172.20.0.1
43+
# Power Smash
44+
iptables -t nat -A DCNET_PRERT -d 172.17.18.2/32 -p tcp -j DNAT --to-destination 172.20.0.1
4945
# Toy Racer (BBA)
5046
iptables -t nat -A DCNET_PRERT -d 24.233.108.248/32 -j DNAT --to-destination 172.20.0.1
5147
# redirect dcnet.flyca.st external IP to internal for dcnet users

0 commit comments

Comments
 (0)