From bc78d3a123d9850cf841e5e0f35baa96d5d94da8 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 1 Dec 2025 15:06:31 +0100 Subject: [PATCH] move to codeberg --- .woodpecker/build.yaml | 18 +++++++ .woodpecker/release.sh | 54 +++++++++++++++++++++ .woodpecker/release.yaml | 31 ++++++++++++ Makefile | 2 +- README.md | 7 ++- meson.build | 88 ++++++++++++++++++++++++++++++++++ meson_options.txt | 1 + platform.h.in | 101 +++++++++++++++++++++++++++++++++++++++ udpxd.1 | 44 ++++++++++------- udpxd.h | 23 +++++---- udpxd.pod | 2 +- 11 files changed, 337 insertions(+), 34 deletions(-) create mode 100644 .woodpecker/build.yaml create mode 100755 .woodpecker/release.sh create mode 100644 .woodpecker/release.yaml create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 platform.h.in diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..bd79b3b --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,18 @@ +matrix: + platform: + - linux/amd64 + +labels: + platform: ${platform} + +steps: + build-berkeley: + when: + event: [push] + image: alpine:latest + commands: + - apk update + - apk add --no-cache bash build-base gdb pkgconfig meson ninja + - meson setup --reconfigure build + - ninja -C build + diff --git a/.woodpecker/release.sh b/.woodpecker/release.sh new file mode 100755 index 0000000..a44513a --- /dev/null +++ b/.woodpecker/release.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# This is my own simple codeberg generic releaser. It takes to +# binaries to be uploaded as arguments and takes every other args from +# env. Works on tags or normal commits (push), tags must start with v. + + +set -e + +die() { + echo $* + exit 1 +} + +if test -z "$DEPLOY_TOKEN"; then + die "token DEPLOY_TOKEN not set" +fi + +git fetch --all + +# determine current tag or commit hash +version="$CI_COMMIT_TAG" +previous="" +log="" +if test -z "$version"; then + version="${CI_COMMIT_SHA:0:6}" + log=$(git log -1 --oneline) +else + previous=$(git tag -l | grep -E "^v" | tac | grep -A1 "$version" | tail -1) + log=$(git log -1 --oneline "${previous}..${version}" | sed 's|^|- |g') +fi + +# release body +printf "# Changes\n\n %s\n" "$log" > body.txt + +# create the release +https --ignore-stdin --check-status -b -A bearer -a "$DEPLOY_TOKEN" POST \ + "https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases" \ + tag_name="$version" name="Release $version" body=@body.txt > release.json + +# we need the id to upload files +ID=$(jq -r .id < release.json) + +if test -z "$ID"; then + cat release.json + die "failed to create release" +fi + +# actually upload +for file in "$@"; do + https --ignore-stdin --check-status -A bearer -a "$DEPLOY_TOKEN" -f POST \ + "https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/$ID/assets" \ + "name=${file}" "attachment@${file}" +done diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml new file mode 100644 index 0000000..ec3df19 --- /dev/null +++ b/.woodpecker/release.yaml @@ -0,0 +1,31 @@ +# build release + +labels: + platform: linux/amd64 + +steps: + compile: + when: + event: [tag,manual] + image: alpine:latest + commands: + - apk update + - apk add --no-cache bash build-base words-en gdb pkgconfig meson ninja git + - meson setup --reconfigure --prefer-static -Dcpp_link_args="-static" --buildtype=release build + - ninja -C build + - meson dist -C build --formats xztar,gztar,zip + - file build/udpxd + - mv build/udpxd udpxd-linux-amd64-$CI_COMMIT_TAG + - mv build/meson-dist/* . + + release: + image: alpine:latest + when: + event: [tag,manual] + environment: + DEPLOY_TOKEN: + from_secret: DEPLOY_TOKEN + commands: + - apk update + - apk add --no-cache bash httpie jq git + - .woodpecker/release.sh udpxd-* diff --git a/Makefile b/Makefile index 9cd229f..3f38dc2 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ $(DST): $(OBJS) $(CC) -c $(CFLAGS) $*.c -o $*.o clean: - rm -f *.o $(DST) + rm -rf *.o $(DST) build .cache man: pod2man udpxd.pod > udpxd.1 diff --git a/README.md b/README.md index 54483b0..1a2ef35 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ you need either BSD make or GNU make installed to build it. First you need to check out the source code. Skip this, if you have already done so: - git clone git@github.com:TLINDEN/udpxd.git + git clone https://codeberg.org/scip/udpxd.git Next, change into the newly created directory 'udpxd' and compile the source code: @@ -53,8 +53,7 @@ Although I'm happy to hear from udpxd users in private email, that's the best way for me to forget to do something. In order to report a bug, unexpected behavior, feature requests -or to submit a patch, please open an issue on github: -https://github.com/TLINDEN/udpxd/issues. +or to submit a patch, [please open an issue](https://codeberg.org/scip/udpxd/issues). ## Copyright and license @@ -66,4 +65,4 @@ T.v.Dein ## Project homepage -https://github.com/TLINDEN/udpxd +https://codeberg.org/scip/udpxd diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..18760f4 --- /dev/null +++ b/meson.build @@ -0,0 +1,88 @@ +# -*-python-*- + +project( + 'udpxd', + 'c', + license: 'GPL', + version: '0.0.4', + meson_version: '>=1.3', + default_options: [ + 'warning_level=2', + 'werror=true', + ], +) + +add_project_arguments( + [ + '-Wno-unused-parameter', + '-Wno-unused-result', + '-Wno-missing-braces', + '-Wno-format-zero-length', + '-Wvla', + '-Wno-sign-compare', + '-Wno-narrowing' + ], + language: 'cpp', +) + + +c = meson.get_compiler('c') +conf = configuration_data() + + +# check for funcs. +foreach func : ['getopt', 'malloc', 'fprintf', 'strncpy', 'strlen', 'strtok', 'strchr', 'signal', + 'select', 'free', 'perror', 'getsockname', 'setegid', 'seteuid', 'syslog', + 'va_start', 'va_end', 'inet_ntop', 'getifaddrs', 'getnameinfo', 'ntohs', 'memcpy', 'memset', 'sprintf' ] + conf.set('HAVE_'+func.to_upper(), c.has_function(func, prefix : '#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n')) +endforeach + + +# check commandline options +prefix = get_option('prefix') + +if get_option('buildtype') == 'debug' + conf.set('DEBUG', '1') +endif + + + +# setup conf map +version = '@0@'.format(meson.project_version()) +conf.set('prefix', prefix) +conf.set('UDPXD_VERSION', version) + + +# write out the config header +m = configure_file( + input : 'platform.h.in', + output : 'platform.h', + configuration : conf, +) + + +# code +udpxd_sources = files( + 'client.c', + 'host.c', + 'log.c', + 'net.c', + 'udpxd.c' +) + + + +executable( + 'udpxd', + [udpxd_sources], + install: true +) + +# build manual page +pod2man = find_program('pod2man', native: true) +if pod2man.found() + res = run_command(pod2man.full_path(), 'udpxd.pod', 'udpxd.1', check:true) + if res.returncode() == 0 + install_man('udpxd.1') + endif +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..e62869c --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +# custom build options diff --git a/platform.h.in b/platform.h.in new file mode 100644 index 0000000..a2b742f --- /dev/null +++ b/platform.h.in @@ -0,0 +1,101 @@ +/* platform.h.in. Generated from configure.ac by autoheader. */ + +#define PACKAGE "udpxd" +#define UDPXD_VERSION "@VERSION@" + +#mesondefine HAVE_GETOPT +#ifndef HAVE_GETOPT +error "HAVE_GETOPT not defined" +#endif +#mesondefine HAVE_MALLOC +#ifndef HAVE_MALLOC + error "HAVE_MALLOC not defined" +#endif +#mesondefine HAVE_FPRINTF +#ifndef HAVE_FPRINTF + error "HAVE_FPRINTF not defined" +#endif +#mesondefine HAVE_STRNCPY +#ifndef HAVE_STRNCPY + error "HAVE_STRNCPY not defined" +#endif +#mesondefine HAVE_STRLEN +#ifndef HAVE_STRLEN + error "HAVE_STRLEN not defined" +#endif +#mesondefine HAVE_STRTOK +#ifndef HAVE_STRTOK + error "HAVE_STRTOK not defined" +#endif +#mesondefine HAVE_STRCHR +#ifndef HAVE_STRCHR + error "HAVE_STRCHR not defined" +#endif +#mesondefine HAVE_SIGNAL +#ifndef HAVE_SIGNAL + error "HAVE_SIGNAL not defined" +#endif +#mesondefine HAVE_SELECT +#ifndef HAVE_SELECT + error "HAVE_SELECT not defined" +#endif +#mesondefine HAVE_FREE +#ifndef HAVE_FREE + error "HAVE_FREE not defined" +#endif +#mesondefine HAVE_PERROR +#ifndef HAVE_PERROR + error "HAVE_PERROR not defined" +#endif +#mesondefine HAVE_GETSOCKNAME +#ifndef HAVE_GETSOCKNAME + error "HAVE_GETSOCKNAME not defined" +#endif +#mesondefine HAVE_SETEGID +#ifndef HAVE_SETEGID + error "HAVE_SETEGID not defined" +#endif +#mesondefine HAVE_SETEUID +#ifndef HAVE_SETEUID + error "HAVE_SETEUID not defined" +#endif +#mesondefine HAVE_SYSLOG +#ifndef HAVE_SYSLOG + error "HAVE_SYSLOG not defined" +#endif +#mesondefine HAVE_VA_START +#ifndef HAVE_VA_START + error "HAVE_VA_START not defined" +#endif +#mesondefine HAVE_VA_END +#ifndef HAVE_VA_END + error "HAVE_VA_END not defined" +#endif +#mesondefine HAVE_INET_NTOP +#ifndef HAVE_INET_NTOP + error "HAVE_INET_NTOP not defined" +#endif +#mesondefine HAVE_GETIFADDRS +#ifndef HAVE_GETIFADDRS + error "HAVE_GETIFADDRS not defined" +#endif +#mesondefine HAVE_GETNAMEINFO +#ifndef HAVE_GETNAMEINFO + error "HAVE_GETNAMEINFO not defined" +#endif +#mesondefine HAVE_NTOHS +#ifndef HAVE_NTOHS + error "HAVE_NTOHS not defined" +#endif +#mesondefine HAVE_MEMCPY +#ifndef HAVE_MEMCPY + error "HAVE_MEMCPY not defined" +#endif +#mesondefine HAVE_MEMSET +#ifndef HAVE_MEMSET + error "HAVE_MEMSET not defined" +#endif +#mesondefine HAVE_SPRINTF +#ifndef HAVE_SPRINTF + error "HAVE_SPRINTF not defined" +#endif diff --git a/udpxd.1 b/udpxd.1 index c3b5be4..563fad8 100644 --- a/udpxd.1 +++ b/udpxd.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== @@ -38,27 +38,36 @@ . ds PI \(*p . ds L" `` . ds R" '' +. ds C` +. ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" -.\" If the F register is turned on, we'll generate index entries on stderr for +.\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX .. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -124,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "UDPXD 1" -.TH UDPXD 1 "2015-2016-04-27" "perl v5.14.2" "User Contributed Perl Documentation" +.TH UDPXD 1 "2025-12-01" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -138,7 +147,8 @@ udpxd \- A general purpose UDP relay/port forwarder/proxy \& \& Options: \& \-\-listen \-l listen for incoming requests -\& \-\-bind \-b bind ip used for outgoing requests +\& \-\-bind \-b bind ip used for outgoing requests +\& specify port for promiscuous mode \& \-\-to \-t destination to forward requests to \& \-\-daemon \-d daemon mode, fork into background \& \-\-pidfile \-p pidfile, default: /var/run/udpxd.pid @@ -178,7 +188,9 @@ the background and becomes a daemon. It writes it pidfile to \&\f(CW\*(C`/var/run/udpxd.pid\*(C'\fR, which can be changed with the \fB\-p\fR option. If started as root, it also drops privileges to the user \f(CW\*(C`nobody\*(C'\fR or the user specified with \fB\-u\fR and chroots -to \f(CW\*(C`/var/empty\*(C'\fR or the directory specified with \fB\-c\fR. +to \f(CW\*(C`/var/empty\*(C'\fR or the directory specified with \fB\-c\fR. udpxd +will log to syslog facility user.info if \fB\-v\fR is specified and +if running in daemon mode. .PP \&\fBCaution: if not running in daemon mode, udpxd does not drop its privileges and will continue to run as root (if started as @@ -275,12 +287,12 @@ address: .IX Header "BUGS" In order to report a bug, unexpected behavior, feature requests or to submit a patch, please open an issue on github: -. +. .SH "LICENSE" .IX Header "LICENSE" -This software is licensed under the \s-1GNU\s0 \s-1GENERAL\s0 \s-1PUBLIC\s0 \s-1LICENSE\s0 version 3. +This software is licensed under the \s-1GNU GENERAL PUBLIC LICENSE\s0 version 3. .PP -Copyright (c) 2015-2016 by T. v. Dein. +Copyright (c) 2015\-2017 by T. v. Dein. .PP This software uses \fButhash\fR (bundled), which is Copyright (c) 2003\-2013 by Troy D. Hanson. diff --git a/udpxd.h b/udpxd.h index bac015d..02c98ff 100644 --- a/udpxd.h +++ b/udpxd.h @@ -22,22 +22,21 @@ #ifndef _HAVE_UDPXD_H #define _HAVE_UDPXD_H -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include #include +#include +#include +#include +#include -#define UDPXD_VERSION "0.0.4" - +#include "platform.h" void usage(); int parse_ip(char *src, char *ip, char *pt); diff --git a/udpxd.pod b/udpxd.pod index 6e68c04..25c7f82 100644 --- a/udpxd.pod +++ b/udpxd.pod @@ -135,7 +135,7 @@ B: created if running in daemon mode (B<-d>). In order to report a bug, unexpected behavior, feature requests or to submit a patch, please open an issue on github: -L. +L. =head1 LICENSE