mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-06-22 13:59:26 +00:00
Compare commits
1 Commits
64833d7af8
...
2622e4f7d6
| Author | SHA1 | Date | |
|---|---|---|---|
| 2622e4f7d6 |
35
.github/workflows/appimage-build.yml
vendored
35
.github/workflows/appimage-build.yml
vendored
@@ -29,7 +29,6 @@ jobs:
|
||||
build-essential pkg-config meson ninja-build cmake \
|
||||
gettext \
|
||||
libcanberra-dev libglib2.0-dev \
|
||||
libminiupnpc-dev \
|
||||
libarchive-dev \
|
||||
libgtk-3-dev \
|
||||
libwayland-client0 libwayland-cursor0 libwayland-egl1 \
|
||||
@@ -87,21 +86,11 @@ jobs:
|
||||
cp -a /usr/lib/x86_64-linux-gnu/python3/dist-packages AppDir/usr/lib/x86_64-linux-gnu/python3/
|
||||
fi
|
||||
|
||||
if [ -d "/usr/lib/x86_64-linux-gnu/perl-base" ]; then
|
||||
install -d AppDir/usr/lib/x86_64-linux-gnu
|
||||
cp -a /usr/lib/x86_64-linux-gnu/perl-base AppDir/usr/lib/x86_64-linux-gnu/
|
||||
fi
|
||||
|
||||
if [ -d "/usr/lib/x86_64-linux-gnu/perl" ]; then
|
||||
install -d AppDir/usr/lib/x86_64-linux-gnu
|
||||
cp -a /usr/lib/x86_64-linux-gnu/perl AppDir/usr/lib/x86_64-linux-gnu/
|
||||
fi
|
||||
|
||||
if [ -d "/usr/lib/x86_64-linux-gnu/perl5" ]; then
|
||||
install -d AppDir/usr/lib/x86_64-linux-gnu
|
||||
cp -a /usr/lib/x86_64-linux-gnu/perl5 AppDir/usr/lib/x86_64-linux-gnu/
|
||||
fi
|
||||
|
||||
if [ -d "/usr/share/perl" ]; then
|
||||
install -d AppDir/usr/share
|
||||
cp -a /usr/share/perl AppDir/usr/share/
|
||||
@@ -111,10 +100,6 @@ jobs:
|
||||
install -d AppDir/usr/share
|
||||
cp -a /usr/share/perl5 AppDir/usr/share/
|
||||
fi
|
||||
|
||||
perl -MFile::Spec -e 'print "Build host File::Spec: $INC{\"File/Spec.pm\"}\n"'
|
||||
find AppDir/usr -path '*/File/Spec.pm' -print -quit | grep -q .
|
||||
|
||||
if compgen -G '/usr/lib/x86_64-linux-gnu/libpython3*.so*' > /dev/null; then
|
||||
install -d AppDir/usr/lib/x86_64-linux-gnu
|
||||
cp -a /usr/lib/x86_64-linux-gnu/libpython3*.so* AppDir/usr/lib/x86_64-linux-gnu/
|
||||
@@ -177,7 +162,7 @@ jobs:
|
||||
|
||||
APPDIR="${APPDIR:-$(dirname "$(readlink -f "$0")")}"
|
||||
|
||||
export PATH="$APPDIR/usr/bin:${PATH:-/usr/bin:/bin}"
|
||||
export PATH="${PATH:-/usr/bin:/bin}:$APPDIR/usr/bin"
|
||||
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-}"
|
||||
export XDG_DATA_DIRS="$APPDIR/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
|
||||
export GTK_EXE_PREFIX="$APPDIR/usr"
|
||||
@@ -226,23 +211,6 @@ jobs:
|
||||
|
||||
unset GTK_MODULES
|
||||
|
||||
perl5lib_entries=""
|
||||
for dir in \
|
||||
"$APPDIR/usr/lib/x86_64-linux-gnu/perl-base" \
|
||||
"$APPDIR/usr/lib/x86_64-linux-gnu/perl"/* \
|
||||
"$APPDIR/usr/lib/x86_64-linux-gnu/perl5"/* \
|
||||
"$APPDIR/usr/share/perl"/* \
|
||||
"$APPDIR/usr/share/perl5"
|
||||
do
|
||||
if [ -d "$dir" ]; then
|
||||
perl5lib_entries="${perl5lib_entries:+$perl5lib_entries:}$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$perl5lib_entries" ]; then
|
||||
export PERL5LIB="$perl5lib_entries${PERL5LIB:+:$PERL5LIB}"
|
||||
fi
|
||||
|
||||
export PYTHONHOME="$APPDIR/usr"
|
||||
python_stdlib_dir="$(find "$APPDIR/usr/lib" -maxdepth 1 -type d -name 'python3.*' | head -n 1 || true)"
|
||||
pythonpath_entries=""
|
||||
@@ -288,6 +256,7 @@ jobs:
|
||||
EOF
|
||||
chmod +x AppRun
|
||||
|
||||
|
||||
VERSION="$(git describe --tags --always)"
|
||||
|
||||
./linuxdeploy-x86_64.AppImage \
|
||||
|
||||
1
.github/workflows/manjaro-package-build.yml
vendored
1
.github/workflows/manjaro-package-build.yml
vendored
@@ -33,7 +33,6 @@ jobs:
|
||||
gtk3 \
|
||||
openssl \
|
||||
libcanberra \
|
||||
miniupnpc \
|
||||
libayatana-appindicator \
|
||||
iso-codes \
|
||||
lua \
|
||||
|
||||
@@ -18,8 +18,6 @@ libgmodule_dep = dependency('gmodule-2.0')
|
||||
|
||||
libcanberra_dep = dependency('libcanberra', version: '>= 0.22',
|
||||
required: get_option('libcanberra'))
|
||||
miniupnpc_dep = dependency('miniupnpc', version: '>= 2.0.0',
|
||||
required: get_option('miniupnpc'))
|
||||
dbus_dep = dependency('gio-2.0', required: get_option('dbus'))
|
||||
|
||||
global_deps = []
|
||||
@@ -42,7 +40,6 @@ config_h.set10('ENABLE_NLS', true)
|
||||
config_h.set('USE_OPENSSL', libssl_dep.found())
|
||||
config_h.set('USE_LIBCANBERRA', libcanberra_dep.found())
|
||||
config_h.set('USE_DBUS', dbus_dep.found())
|
||||
config_h.set('USE_MINIUPNPC', miniupnpc_dep.found())
|
||||
config_h.set('USE_PLUGIN', get_option('plugin'))
|
||||
config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend'))
|
||||
|
||||
@@ -186,7 +183,6 @@ if meson.version().version_compare('>= 0.55.0')
|
||||
'Plugin Support': get_option('plugin'),
|
||||
'DBus Support': dbus_dep.found(),
|
||||
'libcanberra': libcanberra_dep.found(),
|
||||
'miniupnpc': miniupnpc_dep.found(),
|
||||
}, section: 'Features')
|
||||
|
||||
summary({
|
||||
|
||||
@@ -19,9 +19,6 @@ option('dbus', type: 'feature', value: 'auto',
|
||||
option('libcanberra', type: 'feature', value: 'auto',
|
||||
description: 'Support for sound alerts, Unix only'
|
||||
)
|
||||
option('miniupnpc', type: 'feature', value: 'auto',
|
||||
description: 'Support for DCC Universal Plug & Play, Unix only'
|
||||
)
|
||||
option('appindicator', type: 'feature', value: 'auto',
|
||||
description: 'Use Ayatana/AppIndicator-based tray backend for GTK frontend (non-Windows only)'
|
||||
)
|
||||
|
||||
@@ -13,7 +13,6 @@ depends=(
|
||||
'iso-codes'
|
||||
'libayatana-appindicator'
|
||||
'libcanberra'
|
||||
'miniupnpc'
|
||||
'lua'
|
||||
'openssl'
|
||||
'perl'
|
||||
|
||||
@@ -390,6 +390,9 @@ const struct prefs vars[] =
|
||||
{"dcc_permissions", P_OFFINT (hex_dcc_permissions), TYPE_INT},
|
||||
{"dcc_port_first", P_OFFINT (hex_dcc_port_first), TYPE_INT},
|
||||
{"dcc_port_last", P_OFFINT (hex_dcc_port_last), TYPE_INT},
|
||||
{"dcc_nat_lease", P_OFFINT (hex_dcc_nat_lease), TYPE_INT},
|
||||
{"dcc_nat_map", P_OFFINT (hex_dcc_nat_map), TYPE_BOOL},
|
||||
{"dcc_passive_prefer", P_OFFINT (hex_dcc_passive_prefer), TYPE_BOOL},
|
||||
{"dcc_remove", P_OFFINT (hex_dcc_remove), TYPE_BOOL},
|
||||
{"dcc_save_nick", P_OFFINT (hex_dcc_save_nick), TYPE_BOOL},
|
||||
{"dcc_send_fillspaces", P_OFFINT (hex_dcc_send_fillspaces), TYPE_BOOL},
|
||||
@@ -562,7 +565,6 @@ const struct prefs vars[] =
|
||||
{"net_proxy_user", P_OFFSET (hex_net_proxy_user), TYPE_STR},
|
||||
{"net_reconnect_delay", P_OFFINT (hex_net_reconnect_delay), TYPE_INT},
|
||||
{"net_throttle", P_OFFINT (hex_net_throttle), TYPE_BOOL},
|
||||
{"net_upnp", P_OFFINT (hex_net_upnp), TYPE_BOOL},
|
||||
|
||||
{"notify_timeout", P_OFFINT (hex_notify_timeout), TYPE_INT},
|
||||
{"notify_whois_online", P_OFFINT (hex_notify_whois_online), TYPE_BOOL},
|
||||
@@ -763,6 +765,7 @@ load_default_config(void)
|
||||
prefs.hex_away_show_once = 1;
|
||||
prefs.hex_away_track = 1;
|
||||
prefs.hex_dcc_auto_resume = 1;
|
||||
prefs.hex_dcc_passive_prefer = 1;
|
||||
#ifndef WIN32
|
||||
prefs.hex_dcc_fast_send = 1;
|
||||
#endif
|
||||
@@ -812,7 +815,6 @@ load_default_config(void)
|
||||
prefs.hex_irc_whois_front = 1;
|
||||
prefs.hex_net_auto_reconnect = 1;
|
||||
prefs.hex_net_throttle = 1;
|
||||
prefs.hex_net_upnp = 1;
|
||||
prefs.hex_stamp_log = 1;
|
||||
prefs.hex_stamp_text = 1;
|
||||
prefs.hex_text_autocopy_text = 1;
|
||||
@@ -837,6 +839,7 @@ load_default_config(void)
|
||||
prefs.hex_dcc_permissions = 0600;
|
||||
prefs.hex_dcc_stall_timeout = 60;
|
||||
prefs.hex_dcc_timeout = 180;
|
||||
prefs.hex_dcc_nat_lease = 1800;
|
||||
prefs.hex_flood_ctcp_num = 5;
|
||||
prefs.hex_flood_ctcp_time = 30;
|
||||
prefs.hex_flood_msg_num = 5;
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
<ClCompile Include="sysinfo\win32\backend.c" />
|
||||
<ClCompile Include="text.c" />
|
||||
<ClCompile Include="tree.c" />
|
||||
<ClCompile Include="upnp.c" />
|
||||
<ClCompile Include="url.c" />
|
||||
<ClCompile Include="userlist.c" />
|
||||
<ClCompile Include="util.c" />
|
||||
|
||||
@@ -190,9 +190,6 @@
|
||||
<ClCompile Include="tree.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="upnp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="url.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
#include "text.h"
|
||||
#include "url.h"
|
||||
#include "zoitechatc.h"
|
||||
#include "upnp.h"
|
||||
|
||||
/* Setting _FILE_OFFSET_BITS to 64 doesn't change lseek to use off64_t on Windows, so override lseek to the version that does */
|
||||
#if defined(WIN32) && (!defined(__MINGW32__) && !defined(__MINGW64__))
|
||||
@@ -88,6 +87,41 @@ static gboolean dcc_read (GIOChannel *, GIOCondition, struct DCC *);
|
||||
static gboolean dcc_read_ack (GIOChannel *source, GIOCondition condition, struct DCC *dcc);
|
||||
static int dcc_check_timeouts (void);
|
||||
|
||||
|
||||
static int
|
||||
nat_map_run (int add, int port, int proto, int lease)
|
||||
{
|
||||
char cmd[512];
|
||||
int status = 0;
|
||||
if (add)
|
||||
g_snprintf (cmd, sizeof (cmd), "upnpc -a 127.0.0.1 %d %d TCP %d >/dev/null 2>&1", port, port, lease);
|
||||
else
|
||||
g_snprintf (cmd, sizeof (cmd), "upnpc -d %d TCP >/dev/null 2>&1", port);
|
||||
if (!g_spawn_command_line_sync (cmd, NULL, NULL, &status, NULL))
|
||||
return FALSE;
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
dcc_nat_unmap (struct DCC *dcc)
|
||||
{
|
||||
if (!dcc->map_port)
|
||||
return;
|
||||
nat_map_run (0, dcc->map_port, dcc->type, 0);
|
||||
dcc->map_port = 0;
|
||||
dcc->map_next_refresh = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
dcc_nat_refresh (struct DCC *dcc)
|
||||
{
|
||||
if (!dcc->map_port || prefs.hex_dcc_nat_lease <= 0)
|
||||
return;
|
||||
if (time (0) < dcc->map_next_refresh)
|
||||
return;
|
||||
if (nat_map_run (1, dcc->map_port, dcc->type, prefs.hex_dcc_nat_lease))
|
||||
dcc->map_next_refresh = time (0) + prefs.hex_dcc_nat_lease / 2;
|
||||
}
|
||||
static int new_id(void)
|
||||
{
|
||||
static int id = 0;
|
||||
@@ -255,7 +289,8 @@ dcc_check_timeouts (void)
|
||||
switch (dcc->dccstat)
|
||||
{
|
||||
case STAT_ACTIVE:
|
||||
dcc_calc_cps (dcc);
|
||||
dcc_calc_cps (dcc);
|
||||
dcc_nat_refresh (dcc);
|
||||
fe_dcc_update (dcc);
|
||||
|
||||
if (dcc->type == TYPE_SEND || dcc->type == TYPE_RECV)
|
||||
@@ -372,12 +407,6 @@ dcc_connect_sok (struct DCC *dcc)
|
||||
static void
|
||||
dcc_close (struct DCC *dcc, enum dcc_state dccstat, int destroy)
|
||||
{
|
||||
if (dcc->port > 0)
|
||||
{
|
||||
if (prefs.hex_net_upnp)
|
||||
upnp_rem_redir(dcc->port);
|
||||
}
|
||||
|
||||
if (dcc->wiotag)
|
||||
{
|
||||
fe_input_remove (dcc->wiotag);
|
||||
@@ -397,6 +426,7 @@ dcc_close (struct DCC *dcc, enum dcc_state dccstat, int destroy)
|
||||
}
|
||||
|
||||
dcc_remove_from_sum (dcc);
|
||||
dcc_nat_unmap (dcc);
|
||||
|
||||
if (dcc->fp != -1)
|
||||
{
|
||||
@@ -1705,6 +1735,11 @@ dcc_listen_init (struct DCC *dcc, session *sess)
|
||||
getsockname (dcc->sok, (struct sockaddr *) &SAddr, &len);
|
||||
|
||||
dcc->port = ntohs (SAddr.sin_port);
|
||||
if (prefs.hex_dcc_nat_map && nat_map_run (1, dcc->port, dcc->type, prefs.hex_dcc_nat_lease))
|
||||
{
|
||||
dcc->map_port = dcc->port;
|
||||
dcc->map_next_refresh = time (0) + prefs.hex_dcc_nat_lease / 2;
|
||||
}
|
||||
|
||||
dcc->addr = dcc_get_my_address (sess);
|
||||
|
||||
@@ -1718,8 +1753,6 @@ dcc_listen_init (struct DCC *dcc, session *sess)
|
||||
set_blocking (dcc->sok);
|
||||
|
||||
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_accept, dcc);
|
||||
if (prefs.hex_net_upnp)
|
||||
upnp_add_redir(inet_ntoa(SAddr.sin_addr), dcc->port);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1855,8 +1888,19 @@ dcc_send (struct session *sess, char *to, char *filename, gint64 maxcps, int pas
|
||||
return;
|
||||
}
|
||||
|
||||
if (passive || dcc_listen_init (dcc, sess))
|
||||
if ((passive || prefs.hex_dcc_passive_prefer) || dcc_listen_init (dcc, sess))
|
||||
{
|
||||
if (passive || prefs.hex_dcc_passive_prefer)
|
||||
{
|
||||
guint32 offer_addr = dcc_get_my_address (sess);
|
||||
struct sockaddr_in saddr;
|
||||
socklen_t slen = sizeof (saddr);
|
||||
memset (&saddr, 0, sizeof (saddr));
|
||||
getsockname (dcc->serv->sok, (struct sockaddr *) &saddr, &slen);
|
||||
if (offer_addr == 0)
|
||||
offer_addr = prefs.local_ip != 0xffffffff ? prefs.local_ip : saddr.sin_addr.s_addr;
|
||||
dcc->addr = ntohl (offer_addr);
|
||||
}
|
||||
char havespaces = 0;
|
||||
while (*filename)
|
||||
{
|
||||
@@ -1877,13 +1921,13 @@ dcc_send (struct session *sess, char *to, char *filename, gint64 maxcps, int pas
|
||||
} else
|
||||
fe_dcc_add (dcc);
|
||||
|
||||
if (passive)
|
||||
if (passive || prefs.hex_dcc_passive_prefer)
|
||||
{
|
||||
dcc->pasvid = new_id();
|
||||
g_snprintf (outbuf, sizeof (outbuf), (havespaces) ?
|
||||
"DCC SEND \"%s\" 199 0 %" G_GUINT64_FORMAT " %d" :
|
||||
"DCC SEND %s 199 0 %" G_GUINT64_FORMAT " %d",
|
||||
file_part (dcc->file),
|
||||
"DCC SEND \"%s\" %u 0 %" G_GUINT64_FORMAT " %d" :
|
||||
"DCC SEND %s %u 0 %" G_GUINT64_FORMAT " %d",
|
||||
file_part (dcc->file), dcc->addr,
|
||||
dcc->size, dcc->pasvid);
|
||||
}
|
||||
else
|
||||
@@ -2301,8 +2345,19 @@ dcc_chat (struct session *sess, char *nick, int passive)
|
||||
dcc->dccstat = STAT_QUEUED;
|
||||
dcc->type = TYPE_CHATSEND;
|
||||
dcc->nick = g_strdup (nick);
|
||||
if (passive || dcc_listen_init (dcc, sess))
|
||||
if ((passive || prefs.hex_dcc_passive_prefer) || dcc_listen_init (dcc, sess))
|
||||
{
|
||||
if (passive || prefs.hex_dcc_passive_prefer)
|
||||
{
|
||||
guint32 offer_addr = dcc_get_my_address (sess);
|
||||
struct sockaddr_in saddr;
|
||||
socklen_t slen = sizeof (saddr);
|
||||
memset (&saddr, 0, sizeof (saddr));
|
||||
getsockname (dcc->serv->sok, (struct sockaddr *) &saddr, &slen);
|
||||
if (offer_addr == 0)
|
||||
offer_addr = prefs.local_ip != 0xffffffff ? prefs.local_ip : saddr.sin_addr.s_addr;
|
||||
dcc->addr = ntohl (offer_addr);
|
||||
}
|
||||
if (prefs.hex_gui_autoopen_chat)
|
||||
{
|
||||
if (fe_dcc_open_chat_win (TRUE)) /* already open? add only */
|
||||
@@ -2310,11 +2365,11 @@ dcc_chat (struct session *sess, char *nick, int passive)
|
||||
} else
|
||||
fe_dcc_add (dcc);
|
||||
|
||||
if (passive)
|
||||
if (passive || prefs.hex_dcc_passive_prefer)
|
||||
{
|
||||
dcc->pasvid = new_id ();
|
||||
g_snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat 199 %d %d",
|
||||
dcc->port, dcc->pasvid);
|
||||
g_snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat %u 0 %d",
|
||||
dcc->addr, dcc->pasvid);
|
||||
} else
|
||||
{
|
||||
g_snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat %u %d",
|
||||
|
||||
@@ -55,6 +55,9 @@ struct DCC
|
||||
int wiotag; /* writing/sending io tag */
|
||||
int port;
|
||||
int pasvid; /* mIRC's passive DCC id */
|
||||
int map_port;
|
||||
int map_proto;
|
||||
int map_next_refresh;
|
||||
gint64 cps;
|
||||
int resume_error;
|
||||
int resume_errno;
|
||||
|
||||
@@ -24,8 +24,7 @@ common_sources = [
|
||||
'tree.c',
|
||||
'url.c',
|
||||
'userlist.c',
|
||||
'util.c',
|
||||
'upnp.c'
|
||||
'util.c'
|
||||
]
|
||||
|
||||
common_sysinfo_deps = []
|
||||
@@ -116,10 +115,6 @@ if libssl_dep.found()
|
||||
common_deps += libssl_dep
|
||||
endif
|
||||
|
||||
if miniupnpc_dep.found()
|
||||
common_deps += miniupnpc_dep
|
||||
endif
|
||||
|
||||
if dbus_dep.found()
|
||||
subdir('dbus')
|
||||
common_deps += zoitechat_dbus_dep
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Thomas Bernard
|
||||
* Copyright (C) HexChat contributors
|
||||
* Copyright (C) ZoiteChat contributors
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "upnp.h"
|
||||
|
||||
#ifdef USE_MINIUPNPC
|
||||
#include <miniupnpc/miniupnpc.h>
|
||||
#include <miniupnpc/upnpcommands.h>
|
||||
#include <miniupnpc/upnperrors.h>
|
||||
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
static int ready;
|
||||
static char upnp_lanaddr[64];
|
||||
|
||||
void
|
||||
upnp_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
int igd = 0;
|
||||
char lanaddr[64] = {0};
|
||||
struct UPNPDev *devlist;
|
||||
|
||||
memset(&urls, 0, sizeof(urls));
|
||||
memset(&data, 0, sizeof(data));
|
||||
ready = 0;
|
||||
upnp_lanaddr[0] = 0;
|
||||
|
||||
devlist = upnpDiscover(2000, NULL, NULL, 0, 0, 2, &err);
|
||||
if (!devlist)
|
||||
devlist = upnpDiscover(2000, NULL, NULL, 0, 1, 2, &err);
|
||||
if (!devlist)
|
||||
return;
|
||||
|
||||
igd = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
|
||||
if (igd == 1 || igd == 2 || igd == 3)
|
||||
{
|
||||
ready = 1;
|
||||
snprintf(upnp_lanaddr, sizeof(upnp_lanaddr), "%s", lanaddr);
|
||||
}
|
||||
|
||||
freeUPNPDevlist(devlist);
|
||||
}
|
||||
|
||||
void
|
||||
upnp_add_redir(const char *addr, int port)
|
||||
{
|
||||
char port_str[16];
|
||||
const char *map_addr;
|
||||
int r;
|
||||
|
||||
if (!ready)
|
||||
upnp_init();
|
||||
if (!ready)
|
||||
return;
|
||||
|
||||
map_addr = upnp_lanaddr[0] ? upnp_lanaddr : addr;
|
||||
if (!map_addr || !map_addr[0])
|
||||
return;
|
||||
|
||||
snprintf(port_str, sizeof(port_str), "%d", port);
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
||||
port_str, port_str, NULL, "zoitechat", "TCP", NULL, NULL);
|
||||
if (r != UPNPCOMMAND_SUCCESS)
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
||||
port_str, port_str, map_addr, "zoitechat", "TCP", NULL, NULL);
|
||||
if (r != UPNPCOMMAND_SUCCESS)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
upnp_rem_redir(int port)
|
||||
{
|
||||
char port_str[16];
|
||||
|
||||
if (!ready)
|
||||
upnp_init();
|
||||
if (!ready)
|
||||
return;
|
||||
|
||||
snprintf(port_str, sizeof(port_str), "%d", port);
|
||||
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port_str, "TCP", NULL);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
upnp_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
upnp_add_redir(const char *addr, int port)
|
||||
{
|
||||
(void)addr;
|
||||
(void)port;
|
||||
}
|
||||
|
||||
void
|
||||
upnp_rem_redir(int port)
|
||||
{
|
||||
(void)port;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Thomas Bernard
|
||||
* Copyright (C) HexChat contributors
|
||||
* Copyright (C) ZoiteChat contributors
|
||||
*/
|
||||
|
||||
#ifndef ZOITECHAT_UPNP_H
|
||||
#define ZOITECHAT_UPNP_H
|
||||
|
||||
void upnp_init(void);
|
||||
void upnp_add_redir(const char *addr, int port);
|
||||
void upnp_rem_redir(int port);
|
||||
|
||||
#endif
|
||||
@@ -54,7 +54,6 @@
|
||||
#include "text.h"
|
||||
#include "url.h"
|
||||
#include "zoitechatc.h"
|
||||
#include "upnp.h"
|
||||
|
||||
#if ! GLIB_CHECK_VERSION (2, 36, 0)
|
||||
#include <glib-object.h> /* for g_type_init() */
|
||||
@@ -962,8 +961,6 @@ xchat_init (void)
|
||||
sound_load ();
|
||||
notify_load ();
|
||||
ignore_load ();
|
||||
if (prefs.hex_net_upnp)
|
||||
upnp_init ();
|
||||
sts_init ();
|
||||
|
||||
g_snprintf (buf, sizeof (buf),
|
||||
|
||||
@@ -117,6 +117,8 @@ struct zoitechatprefs
|
||||
unsigned int hex_dcc_remove;
|
||||
unsigned int hex_dcc_save_nick;
|
||||
unsigned int hex_dcc_send_fillspaces;
|
||||
unsigned int hex_dcc_passive_prefer;
|
||||
unsigned int hex_dcc_nat_map;
|
||||
unsigned int hex_gui_autoopen_chat;
|
||||
unsigned int hex_gui_autoopen_dialog;
|
||||
unsigned int hex_gui_autoopen_recv;
|
||||
@@ -202,7 +204,6 @@ struct zoitechatprefs
|
||||
unsigned int hex_net_auto_reconnectonfail;
|
||||
unsigned int hex_net_proxy_auth;
|
||||
unsigned int hex_net_throttle;
|
||||
unsigned int hex_net_upnp;
|
||||
unsigned int hex_notify_whois_online;
|
||||
unsigned int hex_perl_warnings;
|
||||
unsigned int hex_stamp_log;
|
||||
@@ -242,6 +243,7 @@ struct zoitechatprefs
|
||||
int hex_dcc_permissions;
|
||||
int hex_dcc_port_first;
|
||||
int hex_dcc_port_last;
|
||||
int hex_dcc_nat_lease;
|
||||
int hex_dcc_stall_timeout;
|
||||
int hex_dcc_timeout;
|
||||
int hex_flood_ctcp_num; /* flood */
|
||||
|
||||
@@ -650,7 +650,10 @@ static const setting network_settings[] =
|
||||
{ST_NUMBER, N_("First DCC listen port:"), P_OFFINTNL(hex_dcc_port_first), 0, 0, 65535},
|
||||
{ST_NUMBER, N_("Last DCC listen port:"), P_OFFINTNL(hex_dcc_port_last), 0,
|
||||
(const char **)N_("!Leave ports at zero for full range."), 65535},
|
||||
{ST_TOGGLE, N_("Enable UPnP port mapping for DCC"), P_OFFINTNL(hex_net_upnp), 0, 0, 0},
|
||||
{ST_TOGGLE, N_("Prefer passive DCC"), P_OFFINTNL(hex_dcc_passive_prefer), 0, 0, 0},
|
||||
{ST_TOGGLE, N_("Try UPnP/NAT-PMP/PCP mapping"), P_OFFINTNL(hex_dcc_nat_map), 0, 0, 0},
|
||||
{ST_NUMBER, N_("NAT mapping lease (sec):"), P_OFFINTNL(hex_dcc_nat_lease), 0, 0, 86400},
|
||||
|
||||
{ST_HEADER, N_("Proxy Server"), 0, 0, 0, 0},
|
||||
{ST_ENTRY, N_("Hostname:"), P_OFFSETNL(hex_net_proxy_host), 0, 0, sizeof prefs.hex_net_proxy_host},
|
||||
{ST_NUMBER, N_("Port:"), P_OFFINTNL(hex_net_proxy_port), 0, 0, 65535},
|
||||
|
||||
Reference in New Issue
Block a user