Skip to main content

Port checking service for VM on Golem - Verify network connectivity for Golem providers

Project description

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

# 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

Contributing

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

golem_port_checker-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

golem_port_checker-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file golem_port_checker-0.1.0.tar.gz.

File metadata

  • Download URL: golem_port_checker-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for golem_port_checker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3bc26f44620acfe2342483085cd943bb942d775dea984235d7b838d8a22789d6
MD5 e0036891d331031fdb8546526427a3a4
BLAKE2b-256 e0c9383cf55383f17b6e8c259438491139dcf31f1e50b4e97b5932594266d628

See more details on using hashes here.

File details

Details for the file golem_port_checker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: golem_port_checker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for golem_port_checker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cf775b0dbbc69c024d986ee6112484b4b4a1470eb9dc5faa6c34b1780e32d72
MD5 62b1aca92b6f5c6c6892f60a262e7729
BLAKE2b-256 bcd3e2e88cc9051b48ed97345a051fefc0d452d14cbce7123201badcbb90867c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page