Skip to main content

VM on Golem Port Checker Server

The Port Checker Server provides a critical network verification service for the Golem Network, ensuring providers have proper port accessibility before joining the network. It verifies both local and external port accessibility through a simple REST API.

System Architecture

graph TB
    subgraph Port Checker
        API[FastAPI Service]
        Check[Port Checker]
        Rate[Rate Limiter]
    end
    
    subgraph Providers
        P1[Provider 1]
        P2[Provider 2]
    end
    
    P1 & P2 -->|Verify Ports| API
    API --> Check
    Rate -->|Protect| API

How It Works

Port Verification Flow

sequenceDiagram
    participant P as Provider
    participant PC as Port Checker
    
    P->>PC: Request Port Check
    PC->>PC: Verify Local Binding
    PC->>PC: Test External Access
    PC-->>P: Verification Results
    Note over PC: Multiple retries with delay

The port checker service verifies port accessibility through:

  1. TCP connection attempts to specified ports
  2. Retry mechanism with configurable attempts
  3. Detailed error reporting
  4. Concurrent port checking

Installation

# Clone the repository
git clone https://github.com/golem/vm-on-golem.git
cd vm-on-golem/port-checker-server

# Install dependencies
poetry install

Configuration

The server can be configured through environment variables:

# Server Settings
PORT_CHECKER_HOST="0.0.0.0"
PORT_CHECKER_PORT=9000
PORT_CHECKER_DEBUG=false

# Port Check Settings
PORT_CHECK_RETRIES=3
PORT_CHECK_RETRY_DELAY=1.0
PORT_CHECK_TIMEOUT=5.0

API Reference

Check Ports

POST /check-ports

Request:

{
    "provider_ip": "192.168.1.100",
    "ports": [7466, 50800, 50801]
}

Response:

{
    "success": true,
    "results": {
        "7466": {
            "accessible": true,
            "error": null
        },
        "50800": {
            "accessible": true,
            "error": null
        },
        "50801": {
            "accessible": false,
            "error": "Connection refused"
        }
    },
    "message": "Successfully verified 2 out of 3 ports"
}

Health Check

GET /health

Response:

{
    "status": "ok"
}

Technical Details

Port Verification Process

  1. Request Validation

    • Valid IP address format
    • Port numbers within range (1-65535)
    • Maximum ports per request
  2. Verification Steps

    • TCP connection attempt
    • Configurable timeout
    • Multiple retry attempts
    • Delay between retries
  3. Response Details

    • Per-port accessibility status
    • Detailed error messages
    • Overall success indicator
    • Summary message

Error Handling

The API uses standardized error responses:

{
    "detail": {
        "code": "ERROR_CODE",
        "message": "Human readable message"
    }
}

Common error codes:

  • INVALID_IP: Invalid IP address format
  • INVALID_PORT: Port number out of range
  • CHECK_FAILED: Port check operation failed

Running the Server

Manual Start

# Start the server
poetry run python run.py

# The server will be available at:
# - API: http://localhost:9000
# - Health Check: http://localhost:9000/health
# - OpenAPI Docs: http://localhost:9000/docs

Running as a Systemd Service

The port checker can run as a systemd service for automatic startup and restart:

  1. Install the service file:
sudo cp golem-port-checker.service /etc/systemd/system/
sudo systemctl daemon-reload
  1. (Optional) Configure environment variables:
# Create environment file if you need custom settings
sudo mkdir -p /etc/golem
sudo nano /etc/golem/port-checker.env

# Example environment variables:
PORT_CHECKER_HOST=0.0.0.0
PORT_CHECKER_PORT=9000
PORT_CHECKER_DEBUG=false
  1. Enable and start the service:
sudo systemctl enable golem-port-checker
sudo systemctl start golem-port-checker
  1. Check service status:
sudo systemctl status golem-port-checker
  1. View service logs:
# View all logs
sudo journalctl -u golem-port-checker

# Follow new logs
sudo journalctl -u golem-port-checker -f

The service is configured to:

  • Start automatically on system boot
  • Restart automatically if it crashes
  • Log output to systemd journal

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run the tests
  5. Submit a pull request

Metadata

Release files for golem-port-checker 0.1.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for golem-port-checker 0.1.25
File Size Uploaded Provenance Actions
golem_port_checker-0.1.25.tar.gz 5.1 kB Without provenance Details for golem_port_checker-0.1.25.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for golem-port-checker 0.1.25
File Interpreter ABI Platform Actions
golem_port_checker-0.1.25-py3-none-any.whl Python 3 none any Details for golem_port_checker-0.1.25-py3-none-any.whl

Total release size: 11.0 kB

Release files / golem_port_checker-0.1.25.tar.gz

Download URL golem_port_checker-0.1.25.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
54b6d955363aaa87bfbce6be94dbaceb1b01bb9aafec54e9549b93b1fffe2659
BLAKE2b-256 checksum
How to use checksums
50b4e89f9bd8a6241558c3af9317562351bd2978bede30ef3e57b82b51f712bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.9.23 Linux/6.11.0-1018-azure

Release files / golem_port_checker-0.1.25-py3-none-any.whl

Download URL golem_port_checker-0.1.25-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00b127fd844fcb73e20db7a242fd3a1bb61643b903e33745ba92549f12ba05d5
BLAKE2b-256 checksum
How to use checksums
8ac7ac8a07b6e4c123cf50f8db7f4c8d21c173dd456b0991cace54ede2957e8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.9.23 Linux/6.11.0-1018-azure

Security for golem-port-checker 0.1.25

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page