Skip to main content

Overview

The YSviaversion module provides version adaptation functionality, allowing clients running different YSFlight versions to connect to the server by translating login packets to match the server’s expected version.

Functions

genViaVersion()

def genViaVersion(username: str, finalVersion: int) -> bytes
Generates a modified login packet that ports a player’s connection to a different YSFlight version.
username
str
required
The player’s username (maximum 16 characters)
finalVersion
int
required
The target YSFlight version number to port to (e.g., 20181124 for YSFlight version 20181124)
return
bytes
A binary packet containing:
  • Packet size (4 bytes): Always 24
  • Packet type (4 bytes): Always 1 (LOGON)
  • Username (16 bytes): ASCII-encoded username with null padding
  • Version (4 bytes): The target version number

Packet Structure

The generated packet follows this binary format:
[size: 4 bytes][type: 4 bytes][username: 16 bytes][version: 4 bytes]
  • Size: Total payload size (24 bytes)
  • Type: Packet type identifier (1 for LOGON)
  • Username: 16-byte field with ASCII characters followed by null padding
  • Version: Target version as unsigned 32-bit integer

Example

from lib import YSviaversion

# Port player to YSFlight version 20181124
username = "Player1"
target_version = 20181124

packet = YSviaversion.genViaVersion(username, target_version)
# Returns binary packet ready to send

Usage in Proxy

Version adaptation is automatically applied when a player connects with a different version than the server expects:
# From proxy.py:171-176
if packet_type == "FSNETCMD_LOGON":
    decode = FSNETCMD_LOGON(packet)
    player.login(decode)
    
    if player.version != YSF_VERSION and VIA_VERSION:
        info(f"ViaVersion enabled: Porting {player.username} from {player.version} to {YSF_VERSION}")
        message_to_client.append(YSchat.message(f"Porting you to YSFlight {YSF_VERSION}"))
        message_to_client.append(YSchat.message(f"This is currently Experimental"))
        data = YSviaversion.genViaVersion(player.username, YSF_VERSION)

Configuration

Version adaptation is controlled by configuration variables:
# config.py
VIA_VERSION = True  # Enable/disable version adaptation
YSF_VERSION = 20181124  # Target server version

Notes

  • Usernames longer than 16 characters will be truncated
  • Usernames shorter than 16 characters are padded with null bytes (\x00)
  • Each character is encoded as ASCII bytes
  • The feature is experimental and may not support all version differences
  • Players receive chat notifications when version porting is applied
  • The original login packet is replaced with the generated version-adapted packet

Limitations

  • Only modifies the login packet version field
  • Does not translate protocol differences between versions
  • May not work for significantly different YSFlight versions
  • Experimental feature requiring testing with various version combinations

Build docs developers (and LLMs) love