@@ -117,4 +117,58 @@ public static function guzzleRequest($node)
117117
118118 return self ::$ guzzle [$ node ];
119119 }
120+
121+ /**
122+ * Returns the configuration in JSON format
123+ *
124+ * @param boolean $pretty Wether to pretty print the JSON or not
125+ * @return string The configration in JSON format
126+ */
127+ public function getConfigurationAsJson ($ pretty = false ) {
128+ $ config = array (
129+ 'web ' => array (
130+ 'host ' => '0.0.0.0 ' ,
131+ 'listen ' => $ this ->daemonListen ,
132+ 'ssl ' => array (
133+ 'enabled ' => $ this ->scheme === 'https ' ,
134+ 'certificate ' => '/etc/letsencrypt/live/localhost/fullchain.pem ' ,
135+ 'key ' => '/etc/letsencrypt/live/localhost/privkey.pem '
136+ )
137+ ),
138+ 'docker ' => array (
139+ 'socket ' => '/var/run/docker.sock ' ,
140+ 'autoupdate_images ' => true
141+ ),
142+ 'sftp ' => array (
143+ 'path ' => $ this ->daemonBase ,
144+ 'port ' => $ this ->daemonSFTP ,
145+ 'container ' => 'ptdl-sftp '
146+ ),
147+ 'query ' => array (
148+ 'kill_on_fail ' => true ,
149+ 'fail_limit ' => 5
150+ ),
151+ 'logger ' => array (
152+ 'path ' => 'logs/ ' ,
153+ 'src ' => false ,
154+ 'level ' => 'info ' ,
155+ 'period ' => '1d ' ,
156+ 'count ' => 3
157+ ),
158+ 'remote ' => array (
159+ 'base ' => config ('app.url ' ),
160+ 'download ' => route ('remote.download ' ),
161+ 'installed ' => route ('remote.install ' )
162+ ),
163+ 'uploads ' => array (
164+ 'size_limit ' => $ this ->upload_size
165+ ),
166+ 'keys ' => array ($ this ->daemonSecret )
167+ );
168+
169+ $ json_options = JSON_UNESCAPED_SLASHES ;
170+ if ($ pretty ) $ json_options |= JSON_PRETTY_PRINT ;
171+
172+ return json_encode ($ config , $ json_options );
173+ }
120174}
0 commit comments