# Generated from soulfire/proxy-check.proto. DO NOT EDIT.
# Generated by protoc-gen-connectrpc-py v0.13.0 with parameter "protobuf=google".
# ruff: noqa: PGH004
# ruff: noqa
# pyright: reportDeprecated=false
# ty: ignore[unused-ignore-comment]
# ty: ignore[deprecated, unused-ignore-comment]
# fmt: off
from __future__ import annotations
from typing import Protocol, TYPE_CHECKING
from connectrpc.client import ConnectClient, ConnectClientSync
from connectrpc.code import Code
from connectrpc.compat import google_protobuf_binary_codec, google_protobuf_codecs
from connectrpc.compression.gzip import GzipCompression
from connectrpc.errors import ConnectError
from connectrpc.method import IdempotencyLevel, MethodInfo, StreamType
from connectrpc.protocol import ProtocolType
from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, DEFAULT_READ_MAX_BYTES, Endpoint, EndpointSync
from pyqwest import Client, SyncClient
from .proxy_check_pb2 import ProxyCheckRequest, ProxyCheckResponse
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Iterator, Mapping
from connectrpc.codec import Codec
from connectrpc.compression import Compression
from connectrpc.interceptor import Interceptor, InterceptorSync
from connectrpc.request import Headers, RequestContext
_DEFAULT_CODECS = google_protobuf_codecs()
_PROTO_BINARY_CODEC = google_protobuf_binary_codec()
_GZIP_COMPRESSION = GzipCompression()
[docs]
class ProxyCheckService(Protocol):
"""
Service for validating proxy servers by testing their ability to connect
to Minecraft servers. This is useful for filtering out dead or slow proxies
before using them for bot connections.
The service tests proxies by attempting to establish a Minecraft protocol
connection through each proxy to a configurable target server and waiting
for a status response packet. Results include whether the proxy works and
its latency.
"""
[docs]
def check(self, request: ProxyCheckRequest, ctx: RequestContext[ProxyCheckRequest, ProxyCheckResponse], /) -> AsyncIterator[ProxyCheckResponse]:
"""
Checks the validity of one or more proxies by attempting to connect
through them to a Minecraft server.
The check process:
1. For each proxy in the request, a connection attempt is made through
the proxy to the Minecraft server configured in the instance settings
2. The connection uses the protocol version configured in the instance
3. A proxy is considered valid if it successfully connects and receives
a server status response within 30 seconds
4. Results are streamed back as each check completes
5. A ProxyCheckEnd message is sent when all checks are complete
Concurrency is controlled by the instance's PROXY_CHECK_CONCURRENCY setting.
Required permission: CHECK_PROXY on the specified instance.
Error cases:
- NOT_FOUND: The specified instance_id does not exist
- PERMISSION_DENIED: The user lacks CHECK_PROXY permission on the instance
- INTERNAL: An unexpected error occurred during proxy checking
The stream can be cancelled by the client at any time, which will
terminate any in-progress proxy checks.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
class ProxyCheckServiceASGIApplication(ConnectASGIApplication[ProxyCheckService]):
def __init__(
self,
service: ProxyCheckService | AsyncGenerator[ProxyCheckService],
*,
interceptors: Iterable[Interceptor] = (),
read_max_bytes: int | None = DEFAULT_READ_MAX_BYTES,
compressions: Iterable[Compression] | None = None,
codecs: Iterable[Codec] | None = _DEFAULT_CODECS,
) -> None:
super().__init__(
service=service,
endpoints=lambda svc: {
"/soulfire.v1.ProxyCheckService/Check": Endpoint.server_stream(
method=MethodInfo(
name="Check",
service_name="soulfire.v1.ProxyCheckService",
input=ProxyCheckRequest,
output=ProxyCheckResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.SERVER_STREAM,
),
function=svc.check,
),
},
interceptors=interceptors,
read_max_bytes=read_max_bytes,
compressions=compressions,
codecs=codecs,
)
@property
def path(self) -> str:
"""Returns the URL path to mount the application to when serving multiple applications."""
return "/soulfire.v1.ProxyCheckService"
[docs]
class ProxyCheckServiceClient(ConnectClient):
"""
Service for validating proxy servers by testing their ability to connect
to Minecraft servers. This is useful for filtering out dead or slow proxies
before using them for bot connections.
The service tests proxies by attempting to establish a Minecraft protocol
connection through each proxy to a configurable target server and waiting
for a status response packet. Results include whether the proxy works and
its latency.
"""
def __init__(
self,
address: str,
*,
codec: Codec | None = _PROTO_BINARY_CODEC,
protocol: ProtocolType = ProtocolType.CONNECT,
accept_compression: Iterable[Compression] | None = None,
send_compression: Compression | None = _GZIP_COMPRESSION,
timeout_ms: int | None = None,
read_max_bytes: int | None = None,
interceptors: Iterable[Interceptor] = (),
http_client: Client | None = None,
) -> None:
super().__init__(
address=address,
codec=codec,
protocol=protocol,
accept_compression=accept_compression,
send_compression=send_compression,
timeout_ms=timeout_ms,
read_max_bytes=read_max_bytes,
interceptors=interceptors,
http_client=http_client,
)
[docs]
def check(
self,
request: ProxyCheckRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> AsyncIterator[ProxyCheckResponse]:
"""
Checks the validity of one or more proxies by attempting to connect
through them to a Minecraft server.
The check process:
1. For each proxy in the request, a connection attempt is made through
the proxy to the Minecraft server configured in the instance settings
2. The connection uses the protocol version configured in the instance
3. A proxy is considered valid if it successfully connects and receives
a server status response within 30 seconds
4. Results are streamed back as each check completes
5. A ProxyCheckEnd message is sent when all checks are complete
Concurrency is controlled by the instance's PROXY_CHECK_CONCURRENCY setting.
Required permission: CHECK_PROXY on the specified instance.
Error cases:
- NOT_FOUND: The specified instance_id does not exist
- PERMISSION_DENIED: The user lacks CHECK_PROXY permission on the instance
- INTERNAL: An unexpected error occurred during proxy checking
The stream can be cancelled by the client at any time, which will
terminate any in-progress proxy checks.
"""
return self.execute_server_stream(
request=request,
method=MethodInfo(
name="Check",
service_name="soulfire.v1.ProxyCheckService",
input=ProxyCheckRequest,
output=ProxyCheckResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.SERVER_STREAM,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
class ProxyCheckServiceSync(Protocol):
"""
Service for validating proxy servers by testing their ability to connect
to Minecraft servers. This is useful for filtering out dead or slow proxies
before using them for bot connections.
The service tests proxies by attempting to establish a Minecraft protocol
connection through each proxy to a configurable target server and waiting
for a status response packet. Results include whether the proxy works and
its latency.
"""
[docs]
def check(self, request: ProxyCheckRequest, ctx: RequestContext[ProxyCheckRequest, ProxyCheckResponse], /) -> Iterator[ProxyCheckResponse]:
"""
Checks the validity of one or more proxies by attempting to connect
through them to a Minecraft server.
The check process:
1. For each proxy in the request, a connection attempt is made through
the proxy to the Minecraft server configured in the instance settings
2. The connection uses the protocol version configured in the instance
3. A proxy is considered valid if it successfully connects and receives
a server status response within 30 seconds
4. Results are streamed back as each check completes
5. A ProxyCheckEnd message is sent when all checks are complete
Concurrency is controlled by the instance's PROXY_CHECK_CONCURRENCY setting.
Required permission: CHECK_PROXY on the specified instance.
Error cases:
- NOT_FOUND: The specified instance_id does not exist
- PERMISSION_DENIED: The user lacks CHECK_PROXY permission on the instance
- INTERNAL: An unexpected error occurred during proxy checking
The stream can be cancelled by the client at any time, which will
terminate any in-progress proxy checks.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
class ProxyCheckServiceWSGIApplication(ConnectWSGIApplication):
def __init__(
self,
service: ProxyCheckServiceSync,
interceptors: Iterable[InterceptorSync] = (),
read_max_bytes: int | None = DEFAULT_READ_MAX_BYTES,
compressions: Iterable[Compression] | None = None,
codecs: Iterable[Codec] | None = _DEFAULT_CODECS,
) -> None:
super().__init__(
endpoints={
"/soulfire.v1.ProxyCheckService/Check": EndpointSync.server_stream(
method=MethodInfo(
name="Check",
service_name="soulfire.v1.ProxyCheckService",
input=ProxyCheckRequest,
output=ProxyCheckResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.SERVER_STREAM,
),
function=service.check,
),
},
interceptors=interceptors,
read_max_bytes=read_max_bytes,
compressions=compressions,
codecs=codecs,
)
@property
def path(self) -> str:
"""Returns the URL path to mount the application to when serving multiple applications."""
return "/soulfire.v1.ProxyCheckService"
[docs]
class ProxyCheckServiceClientSync(ConnectClientSync):
"""
Service for validating proxy servers by testing their ability to connect
to Minecraft servers. This is useful for filtering out dead or slow proxies
before using them for bot connections.
The service tests proxies by attempting to establish a Minecraft protocol
connection through each proxy to a configurable target server and waiting
for a status response packet. Results include whether the proxy works and
its latency.
"""
def __init__(
self,
address: str,
*,
codec: Codec | None = _PROTO_BINARY_CODEC,
protocol: ProtocolType = ProtocolType.CONNECT,
accept_compression: Iterable[Compression] | None = None,
send_compression: Compression | None = _GZIP_COMPRESSION,
timeout_ms: int | None = None,
read_max_bytes: int | None = None,
interceptors: Iterable[InterceptorSync] = (),
http_client: SyncClient | None = None,
) -> None:
super().__init__(
address=address,
codec=codec,
protocol=protocol,
accept_compression=accept_compression,
send_compression=send_compression,
timeout_ms=timeout_ms,
read_max_bytes=read_max_bytes,
interceptors=interceptors,
http_client=http_client,
)
[docs]
def check(
self,
request: ProxyCheckRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> Iterator[ProxyCheckResponse]:
"""
Checks the validity of one or more proxies by attempting to connect
through them to a Minecraft server.
The check process:
1. For each proxy in the request, a connection attempt is made through
the proxy to the Minecraft server configured in the instance settings
2. The connection uses the protocol version configured in the instance
3. A proxy is considered valid if it successfully connects and receives
a server status response within 30 seconds
4. Results are streamed back as each check completes
5. A ProxyCheckEnd message is sent when all checks are complete
Concurrency is controlled by the instance's PROXY_CHECK_CONCURRENCY setting.
Required permission: CHECK_PROXY on the specified instance.
Error cases:
- NOT_FOUND: The specified instance_id does not exist
- PERMISSION_DENIED: The user lacks CHECK_PROXY permission on the instance
- INTERNAL: An unexpected error occurred during proxy checking
The stream can be cancelled by the client at any time, which will
terminate any in-progress proxy checks.
"""
return self.execute_server_stream(
request=request,
method=MethodInfo(
name="Check",
service_name="soulfire.v1.ProxyCheckService",
input=ProxyCheckRequest,
output=ProxyCheckResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.SERVER_STREAM,
),
headers=headers,
timeout_ms=timeout_ms,
)