git: d3068db9d8a2 - main - net/mtg: new port, MTPROTO proxy server for Telegram
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Mar 2026 14:43:17 UTC
The branch main has been updated by tz:
URL: https://cgit.FreeBSD.org/ports/commit/?id=d3068db9d8a2065158cbc0abcb34054ca8d79849
commit d3068db9d8a2065158cbc0abcb34054ca8d79849
Author: Torsten Zuehlsdorff <tz@FreeBSD.org>
AuthorDate: 2026-03-23 20:10:00 +0000
Commit: Torsten Zuehlsdorff <tz@FreeBSD.org>
CommitDate: 2026-03-25 14:42:58 +0000
net/mtg: new port, MTPROTO proxy server for Telegram
PR: 233908
---
net/mtg/Makefile | 30 ++++++++++++++++++++++++
net/mtg/distinfo | 5 ++++
net/mtg/files/mtg.in | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
net/mtg/pkg-descr | 7 ++++++
4 files changed, 108 insertions(+)
diff --git a/net/mtg/Makefile b/net/mtg/Makefile
new file mode 100644
index 000000000000..559940304dae
--- /dev/null
+++ b/net/mtg/Makefile
@@ -0,0 +1,30 @@
+PORTNAME= mtg
+DISTVERSIONPREFIX= v
+DISTVERSION= 2.1.13
+CATEGORIES= net
+
+MAINTAINER= drtr0jan@yandex.ru
+COMMENT= MTPROTO proxy server for Telegram
+WWW= https://github.com/9seconds/mtg
+
+LICENSE= MIT
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+USES= go:1.26+,modules
+
+USE_RC_SUBR= ${PORTNAME}
+
+GO_MODULE= github.com/9seconds/mtg/v2
+GO_BUILDFLAGS+= -ldflags "${LD_FLAG_STRING}" -tags netgo
+
+LD_FLAG_STRING= -s -w -X main.version=${DISTVERSION}
+
+PLIST_FILES= bin/${PORTNAME} \
+ "@sample ${ETCDIR}/config.toml.sample"
+
+post-install:
+ ${MKDIR} ${STAGEDIR}${ETCDIR}
+ ${INSTALL_DATA} ${WRKSRC}/example.config.toml \
+ ${STAGEDIR}${ETCDIR}/config.toml.sample
+
+.include <bsd.port.mk>
diff --git a/net/mtg/distinfo b/net/mtg/distinfo
new file mode 100644
index 000000000000..467f6d6e09fd
--- /dev/null
+++ b/net/mtg/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1772437962
+SHA256 (go/net_mtg/mtg-v2.1.13/v2.1.13.mod) = adbb2b5afc127fdff45cf5ef6b23281010f86b43342f7e5a7d934a532cda5d7e
+SIZE (go/net_mtg/mtg-v2.1.13/v2.1.13.mod) = 2127
+SHA256 (go/net_mtg/mtg-v2.1.13/v2.1.13.zip) = ae3678a289276c619b839886c4ac11096c48ef420f4476d00324329a36f46cc8
+SIZE (go/net_mtg/mtg-v2.1.13/v2.1.13.zip) = 200726
diff --git a/net/mtg/files/mtg.in b/net/mtg/files/mtg.in
new file mode 100644
index 000000000000..fc2fbe708d0d
--- /dev/null
+++ b/net/mtg/files/mtg.in
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# PROVIDE: mtg
+# REQUIRE: NETWORKING
+# KEYWORD: shutdown
+#
+# Add following lines to /etc/rc.conf to enable the MTG:
+#
+# mtg_enable (bool): Set NO by default
+# Set YES to enable daemon
+# mtg_user (user): Set user to run mtg.
+# Default is "root".
+# mtg_group (group): Set group to run mtg.
+# Default is "wheel".
+# mtg_args (str): Set flags used with mtg.
+# Default is "". Use `mtg --help` to get instruction.
+# mtg_syslog_output_enable (string): Set to YES to enable syslog output
+# Default is "NO". See daemon(8).
+# mtg_syslog_output_tag (str): Set syslog tag if syslog enabled.
+# Default is "mtg". See daemon(8).
+# mtg_syslog_output_priority (str): Set syslog priority if syslog enabled.
+# Default is "notice". See daemon(8).
+# mtg_syslog_output_facility (str): Set syslog facility if syslog enabled.
+# Default is "daemon". See daemon(8).
+
+. /etc/rc.subr
+
+name=mtg
+rcvar=mtg_enable
+
+load_rc_config $name
+
+: ${mtg_enable:=no}
+: ${mtg_user:="root"}
+: ${mtg_group:="wheel"}
+: ${mtg_syslog_output_enable:="NO"}
+
+start_precmd="mtg_prestart"
+
+if checkyesno mtg_syslog_output_enable; then
+ if [ -n "${mtg_syslog_output_tag}" ]; then
+ mtg_syslog_output_flags="-T ${mtg_syslog_output_tag}"
+ else
+ mtg_syslog_output_flags="-T ${name}"
+ fi
+ if [ -n "${mtg_syslog_output_priority}" ]; then
+ mtg_syslog_output_flags="${mtg_syslog_output_flags} -s ${mtg_syslog_output_priority}"
+ fi
+
+ if [ -n "${mtg_syslog_output_facility}" ]; then
+ mtg_syslog_output_flags="${mtg_syslog_output_flags} -l ${mtg_syslog_output_facility}"
+ fi
+fi
+
+pidfile="/var/run/${name}.pid"
+command="/usr/sbin/daemon"
+command_args="-f -t ${name} ${mtg_syslog_output_flags} -P ${pidfile} %%PREFIX%%/bin/mtg ${mtg_args}"
+
+mtg_prestart()
+{
+ if [ ! -e "${pidfile}" ]; then
+ install -m 0600 -o "${mtg_user}" -g "${mtg_group}" /dev/null "${pidfile}"
+ fi
+}
+
+run_rc_command "$1"
diff --git a/net/mtg/pkg-descr b/net/mtg/pkg-descr
new file mode 100644
index 000000000000..08b52aa14574
--- /dev/null
+++ b/net/mtg/pkg-descr
@@ -0,0 +1,7 @@
+Mtg is an implementation of MTProto proxy in golang which is intended to be:
+
+- Lightweight. It has to consume as less resources as possible but not by losing maintainability.
+- Easily deployable. I strongly believe that Telegram proxies should follow the way
+ of ShadowSocks: promoted channels is a strange way of doing business I suppose.
+- Single secret. I think that multiple secrets solves no problems and just complexify software.
+- No management WebUI. This is an implementation of simple lightweight proxy.