Compare commits
No commits in common. "9363de2db16cadc8525ec53b99cdc2bf6706884c" and "c14decbd441c7a24359ce55a8df0ed2bd6578ea7" have entirely different histories.
9363de2db1
...
c14decbd44
3 changed files with 25 additions and 25 deletions
|
@ -15,7 +15,7 @@ steps:
|
|||
image: python:3-alpine
|
||||
commands:
|
||||
- python3 -m pip install twine
|
||||
- python3 -m twine upload --repository pypi dist/*
|
||||
- python3 -m twine upload --repository testpypi dist/*
|
||||
environment:
|
||||
TWINE_PASSWORD:
|
||||
from_secret: pypi-token
|
||||
|
@ -27,7 +27,7 @@ steps:
|
|||
image: python:3-alpine
|
||||
commands:
|
||||
- python3 -m pip install twine
|
||||
- python3 -m twine upload --repository-url https://code.minecraftchest1.us/api/packages/minecraftchest1/pypi dist/*
|
||||
- python3 -m twine upload --repository-url https://forgejo.example.com/api/packages/minecraftchest1/pypi dist/*
|
||||
environment:
|
||||
TWINE_USERNAME: minecraftchest1
|
||||
TWINE_PASSWORD:
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
from .dnscode import *
|
|
@ -79,15 +79,15 @@ class CNAME(Record):
|
|||
|
||||
#target: str
|
||||
|
||||
def __init__(self, name: str = '@', ttl: int = 3600, host: str = 'example.com'):
|
||||
def __init__(self, name: str = '@', ttl: int = 3600, target: str = 'example.com'):
|
||||
self.rtype = 'CNAME'
|
||||
self.name = name
|
||||
self.ttl = ttl
|
||||
|
||||
if fqdn.FQDN(host).is_valid:
|
||||
self.data = host
|
||||
if fqdn.FQDN(target).is_valid:
|
||||
self.data = target
|
||||
else:
|
||||
raise InvalidDataException(message=f'{host} is not a valid FQDN')
|
||||
raise InvalidDataException(message=f'{target} is not a valid FQDN')
|
||||
|
||||
@dataclass
|
||||
class MX(Record):
|
||||
|
@ -114,16 +114,16 @@ class NS(Record):
|
|||
|
||||
#target: str
|
||||
|
||||
def __init__(self, name: str = '@', ttl: int = 3600, host: str = 'example.com'):
|
||||
def __init__(self, name: str = '@', ttl: int = 3600, target: str = 'example.com'):
|
||||
self.rtype = 'NS'
|
||||
self.name = name
|
||||
self.ttl = ttl
|
||||
self.host = target
|
||||
self.target = target
|
||||
|
||||
if fqdn.FQDN(host).is_valid:
|
||||
self.data = host
|
||||
if fqdn.FQDN(target).is_valid:
|
||||
self.data = target
|
||||
else:
|
||||
raise InvalidDataException(message=f'{host} is not a valid FQDN')
|
||||
raise InvalidDataException(message=f'{target} is not a valid FQDN')
|
||||
|
||||
@dataclass
|
||||
class PTR(Record):
|
||||
|
@ -178,7 +178,7 @@ class SRV(Record):
|
|||
#target: str
|
||||
|
||||
def __init__(self, name: str = '@', ttl: int = 3600, service: str = "service", protocol: str = 'proto',
|
||||
priority: int = 10, weight: int = 10, port: int = 0, host: str = 'example.com'):
|
||||
priority: int = 10, weight: int = 10, port: int = 0, target: str = 'example.com'):
|
||||
self.rtype = 'SRV'
|
||||
self.name = f"_{service}._{protocol}.{name}"
|
||||
self.ttl = ttl
|
||||
|
@ -195,11 +195,12 @@ class SRV(Record):
|
|||
|
||||
self.data = f"{self.priority} {self.weight} {self.port} {self.target}"
|
||||
|
||||
#@dataclass
|
||||
@dataclass
|
||||
class Zone:
|
||||
"""Represents a DNS zone containing multiple records."""
|
||||
|
||||
origin: str
|
||||
records:list = []
|
||||
records: list = field(default_factory=list)
|
||||
|
||||
def __init__(self, origin: str):
|
||||
"""Initializes a zone with the given origin and ensures it ends with a dot."""
|
||||
|
@ -222,30 +223,30 @@ class Zone:
|
|||
else:
|
||||
return name
|
||||
|
||||
def new_A(self, name: str = '@', ttl: int = 3600, host: str = '0.0.0.0'):
|
||||
def new_A(self, name: str = '@', ttl: int = 3600, data: str = '0.0.0.0'):
|
||||
"""Creates and adds a new A record to the zone."""
|
||||
name = self.__mkfqdn(name)
|
||||
self.add(A(name=name, ttl=ttl, host=host))
|
||||
self.add(A(name=name, ttl=ttl, data=data))
|
||||
|
||||
def new_AAAA(self, name: str = '@', ttl: int = 3600, host: str = '0.0.0.0'):
|
||||
def new_AAAA(self, name: str = '@', ttl: int = 3600, data: str = '0.0.0.0'):
|
||||
"""Creates and adds a new AAAA record to the zone."""
|
||||
name = self.__mkfqdn(name)
|
||||
self.add(AAAA(name=name, ttl=ttl, host=host))
|
||||
self.add(AAAA(name=name, ttl=ttl, data=data))
|
||||
|
||||
def new_CNAME(self, name: str = '@', ttl: int = 3600, host: str = 'example.com'):
|
||||
def new_CNAME(self, name: str = '@', ttl: int = 3600, data: str = 'example.com'):
|
||||
"""Creates and adds a new CNAME record to the zone."""
|
||||
name = self.__mkfqdn(name)
|
||||
self.add(CNAME(name=name, ttl=ttl, host=host))
|
||||
self.add(CNAME(name=name, ttl=ttl, target=data))
|
||||
|
||||
def new_MX(self, name: str = '@', ttl: int = 3600, priority: int = 10, host: str = 'example.com'):
|
||||
"""Creates and adds a new MX record to the zone."""
|
||||
name = self.__mkfqdn(name)
|
||||
self.add(MX(name=name, ttl=ttl, priority=priority, host=host))
|
||||
|
||||
def new_NS(self, name: str = '@', ttl: int = 3600, host: str = 'example.com'):
|
||||
def new_NS(self, name: str = '@', ttl: int = 3600, target: str = 'example.com'):
|
||||
"""Creates and adds a new NS record to the zone."""
|
||||
name = self.__mkfqdn(name)
|
||||
self.add(NS(name=name, ttl=ttl, host=host))
|
||||
self.add(NS(name=name, ttl=ttl, target=target))
|
||||
|
||||
def new_PTR(self, name: str = '@', ttl: int = 3600, host: str = 'example.com'):
|
||||
"""Creates and adds a new PTR record to the zone."""
|
||||
|
@ -260,11 +261,11 @@ class Zone:
|
|||
self.add(SOA(mname=mname, rname=rname, serial=serial, refresh=refresh, retry=retry, expire=expire, ttl=ttl))
|
||||
|
||||
def new_SRV(self, name: str = '@', ttl: int = 3600, service: str = 'service', protocol: str = 'proto',
|
||||
priority: int = 10, weight: int = 10, host: str = 'example.com'):
|
||||
priority: int = 10, weight: int = 10, target: str = 'example.com'):
|
||||
"""Creates and adds a new SRV record to the zone."""
|
||||
name = self.__mkfqdn(name)
|
||||
self.add(SRV(name=name, ttl=ttl, service=service, protocol=protocol,
|
||||
priority=priority, weight=weight, host=host))
|
||||
priority=priority, weight=weight, target=target))
|
||||
|
||||
def new_record(self, name: str = '@', ttl: int = 3600, rtype: str = 'A', data: str = '0.0.0.0'):
|
||||
"""Creates and adds a generic DNS record to the zone."""
|
||||
|
|
Loading…
Add table
Reference in a new issue