mixmoe / HibiAPI

一个实现了多种常用站点的易用化API的程序 / A program that implements easy-to-use APIs for a variety of commonly used sites.
https://api.obfs.dev
Apache License 2.0
548 stars 83 forks source link

IPV6 support ? #402

Closed l3nt7ibr closed 4 months ago

l3nt7ibr commented 4 months ago

请问配置支持监听ipv6地址吗? 我在一台只有ipv6公网的机器上搭建了hibiapi程序 但是我在将以下配置改写成如下形式后程序启动失败了,请问应该改成什么形式能让程序监听ipv6地址的端口?

server:
  host: :: # 监听主机
  port: 29999 # 端口
  gzip: true
mnixry commented 4 months ago

启动失败报错什么?

l3nt7ibr commented 4 months ago
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/confuse/yaml_util.py", line 87, in load_yaml
    return yaml.load(f, Loader=loader)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 577, in fetch_value
    raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
  in "/root/configs/general.yml", line 15, column 10

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/hibiapi", line 5, in <module>
    from hibiapi.__main__ import cli
  File "/usr/local/lib/python3.8/dist-packages/hibiapi/__main__.py", line 10, in <module>
    from hibiapi.utils.config import CONFIG_DIR, DEFAULT_DIR, Config
  File "/usr/local/lib/python3.8/dist-packages/hibiapi/utils/config.py", line 114, in <module>
    Config = GeneralConfig("general")
  File "/usr/local/lib/python3.8/dist-packages/hibiapi/utils/config.py", line 107, in __init__
    super().__init__(name)
  File "/usr/local/lib/python3.8/dist-packages/hibiapi/utils/config.py", line 61, in __init__
    super().__init__(name)
  File "/usr/local/lib/python3.8/dist-packages/confuse/core.py", line 515, in __init__
    self.read()
  File "/usr/local/lib/python3.8/dist-packages/confuse/core.py", line 550, in read
    self._add_user_source()
  File "/usr/local/lib/python3.8/dist-packages/hibiapi/utils/config.py", line 99, in _add_user_source
    self.add(confuse.YamlSource(self._config, optional=True))
  File "/usr/local/lib/python3.8/dist-packages/confuse/sources.py", line 76, in __init__
    self.load()
  File "/usr/local/lib/python3.8/dist-packages/confuse/sources.py", line 84, in load
    value = yaml_util.load_yaml(self.filename,
  File "/usr/local/lib/python3.8/dist-packages/confuse/yaml_util.py", line 89, in load_yaml
    raise ConfigReadError(filename, exc)
confuse.exceptions.ConfigReadError: /root/configs/general.yml could not be read: mapping values are not allowed here
  in "/root/configs/general.yml", line 15, column 10
mnixry commented 4 months ago
server:
  host: '::' # 监听主机
  port: 29999 # 端口
  gzip: true

试试这样

l3nt7ibr commented 4 months ago

好了