Skip to content
Snippets Groups Projects
Commit 7d1460b8 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: allow passing json to app.proxyIPs config to set it

parent a2af32ab
No related branches found
No related tags found
No related merge requests found
Pipeline #18857 passed
Pipeline: Castopod

#18862

    Pipeline: castopod.org

    #18861

      Pipeline: Castopod

      #18860

        ......@@ -192,9 +192,9 @@ class App extends BaseConfig
        * '192.168.5.0/24' => 'X-Real-IP',
        * ]
        *
        * @var array<string, string>
        * @var array<string, string>|string
        */
        public array $proxyIPs = [];
        public $proxyIPs = [];
        /**
        * --------------------------------------------------------------------------
        ......@@ -249,4 +249,36 @@ class App extends BaseConfig
        public ?int $bandwidthLimit = null;
        public ?string $legalNoticeURL = null;
        /**
        * AuthToken Config Constructor
        */
        public function __construct()
        {
        parent::__construct();
        if (is_string($this->proxyIPs)) {
        $array = json_decode($this->proxyIPs, true);
        if (is_array($array)) {
        $this->proxyIPs = $array;
        }
        }
        }
        /**
        * Override parent initEnvValue() to allow for direct setting to array properties values from ENV
        *
        * In order to set array properties via ENV vars we need to set the property to a string value first.
        *
        * @param mixed $property
        */
        protected function initEnvValue(&$property, string $name, string $prefix, string $shortPrefix): void
        {
        // if attempting to set property from ENV, first set to empty string
        if ($name === 'proxyIPs' && $this->getEnvValue($name, $prefix, $shortPrefix) !== null) {
        $property = '';
        }
        parent::initEnvValue($property, $name, $prefix, $shortPrefix);
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment