Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (C) 2005 - 2026 Settlers Freaks <sf-team at siedler25.org>
//
// SPDX-License-Identifier: GPL-2.0-or-later

dockerRegistry = "registry.mytrap.de/"
dockerCredentials = "gitlab-Flow86"
dockerImage = "rttr/cross-compiler/linux/linux-amd64-docker:master"

pipeline {
agent {
label "docker"
}

options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '14', daysToKeepStr: '14', numToKeepStr: '180'))
disableConcurrentBuilds()
}

environment {
DEBIAN_FRONTEND = 'noninteractive'
}

stages {
stage('checkout') {
steps {
dir('libendian') {
checkout scm: [
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true, reference: '', trackingSubmodules: false],
[$class: 'GitLFSPull'],
[$class: 'AuthorInChangelog'],
[$class: 'CleanCheckout']
],
submoduleCfg: [],
userRemoteConfigs: [[name: 'libendian', url: 'https://github.com/Return-To-The-Roots/libendian.git']]
]
}
}
}
stage('build') {
steps {
withDockerRegistry( registry: [credentialsId: dockerCredentials, url: 'https://'+dockerRegistry ] ) {
withDockerContainer(
image: dockerRegistry+dockerImage,
args: " \
--pull=always \
-v $HOME/.ccache:/.ccache \
") {
sh """set -ex
rm -rf build || true
export LIBENDIAN_DIR="\$(pwd)/libendian"
export GENERATOR="Unix Makefiles"
tools/ci/build.sh Debug "" tests
"""
}
}
}
}
}
post {
failure {
mail to: 'sf-team@siedler25.org',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Pipeline failed: ${env.BUILD_URL}"
}
cleanup {
sh 'rm -rf build'
}
}}
14 changes: 10 additions & 4 deletions libs/network/include/s25util/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,24 @@ class ResolvedAddr

class PeerAddr
{
address_t addr;
address_t addr{};
socklen_t addrLen = 0;

public:
/// Uninitilized value!
PeerAddr() = default; //-V730
/// Empty address with room for any address type, e.g. to be filled by Socket::Recv
PeerAddr() = default;
/// Initializes the address to a broadcast on the given port
PeerAddr(unsigned short port);

std::string GetIp() const;
sockaddr* GetAddr();
const sockaddr* GetAddr() const;
int GetSize() const { return sizeof(addr); }
/// Size of the contained address (suitable for sendto)
socklen_t GetSize() const { return addrLen; }
/// Capacity of the underlying storage (suitable for recvfrom)
static constexpr socklen_t GetCapacity() { return sizeof(address_t); }
/// Set the size of the contained address, e.g. after it has been filled by recvfrom
void SetSize(socklen_t size) { addrLen = size; }
};

/// Socket-Wrapper-Klasse für portable TCP/IP-Verbindungen
Expand Down
8 changes: 5 additions & 3 deletions libs/network/src/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ResolvedAddr::~ResolvedAddr()
}
}

PeerAddr::PeerAddr(unsigned short port)
PeerAddr::PeerAddr(unsigned short port) : addrLen(sizeof(sockaddr_in))
{
addr.sa_in.sin_family = AF_INET;
addr.sa_in.sin_addr.s_addr = INADDR_BROADCAST;
Expand Down Expand Up @@ -680,8 +680,10 @@ int Socket::Recv(void* const buffer, const int length, PeerAddr& addr) const
if(!isValid())
return -1;

socklen_t addrLen = addr.GetSize();
return recvfrom(socket_, reinterpret_cast<char*>(buffer), length, 0, addr.GetAddr(), &addrLen);
socklen_t addrLen = PeerAddr::GetCapacity();
const int result = recvfrom(socket_, reinterpret_cast<char*>(buffer), length, 0, addr.GetAddr(), &addrLen);
addr.SetSize(result >= 0 ? addrLen : 0);
return result;
}

/**
Expand Down
Loading