@@ -165,19 +165,27 @@ async fn tokio_main(
165
165
let accessory_started = Arc :: new ( Notify :: new ( ) ) ;
166
166
let accessory_started_cloned = accessory_started. clone ( ) ;
167
167
168
- // preparing AppState and starting webserver
169
- let state = web:: AppState {
170
- config : Arc :: new ( Mutex :: new ( config. clone ( ) ) ) ,
171
- config_file : config_file. into ( ) ,
172
- } ;
173
- let app = web:: app ( state. into ( ) ) ;
174
-
175
- let addr = SocketAddr :: from ( ( [ 0 , 0 , 0 , 0 ] , 80 ) ) ;
176
- info ! ( "Server running at http://{addr}/" ) ;
177
- hyper:: Server :: bind ( & addr)
178
- . serve ( app. into_make_service ( ) )
179
- . await
180
- . unwrap ( ) ;
168
+ if let Some ( ref bindaddr) = config. webserver {
169
+ // preparing AppState and starting webserver
170
+ let state = web:: AppState {
171
+ config : Arc :: new ( Mutex :: new ( config. clone ( ) ) ) ,
172
+ config_file : config_file. into ( ) ,
173
+ } ;
174
+ let app = web:: app ( state. into ( ) ) ;
175
+
176
+ match bindaddr. parse :: < SocketAddr > ( ) {
177
+ Ok ( addr) => {
178
+ info ! ( "{} webserver running at http://{addr}/" , NAME ) ;
179
+ hyper:: Server :: bind ( & addr)
180
+ . serve ( app. into_make_service ( ) )
181
+ . await
182
+ . unwrap ( ) ;
183
+ }
184
+ Err ( e) => {
185
+ error ! ( "{} webserver address/port parse: {}" , NAME , e) ;
186
+ }
187
+ }
188
+ }
181
189
182
190
let wifi_conf = {
183
191
if !config. wired . is_some ( ) {
0 commit comments