1616#include <string.h>
1717struct conf_bind
1818{
19- unsigned short type ;
20- char unix_path [BUFSIZ ],inet_addr [BUFSIZ ];
19+ char inet_addr [BUFSIZ ];
2120 unsigned short inet_port ;
2221};
2322struct conf_map
2423{
2524 unsigned short enable_rewrite ;
26- char from [512 ],to_unix_path [512 ],to_inet_addr [512 ];
27- unsigned short to_type ;
25+ char from [512 ],to_inet_addr [512 ];
2826 unsigned short to_inet_port ;
2927 unsigned short to_inet_hybridmode ;
3028};
@@ -93,18 +91,8 @@ void config_dump(struct conf * source)
9391 break ;
9492 }
9593 printf ("\n[BIND]\n" );
96- switch (source -> bind .type )
97- {
98- case TYPE_UNIX :
99- printf ("Type\t\tUNIX Socket\n" );
100- printf ("Path\t\t%s\n" ,source -> bind .unix_path );
101- break ;
102- case TYPE_INET :
103- printf ("Type\t\tInternet Socket\n" );
104- printf ("Address\t\t%s\n" ,source -> bind .inet_addr );
105- printf ("Port\t\t%d\n" ,source -> bind .inet_port );
106- break ;
107- }
94+ printf ("Address\t\t%s\n" ,source -> bind .inet_addr );
95+ printf ("Port\t\t%d\n" ,source -> bind .inet_port );
10896 for (int i = 0 ;i < source -> relay_count ;i ++ )
10997 {
11098 printf ("\n[RELAY #%d]\n" ,i + 1 );
@@ -118,50 +106,30 @@ void config_dump(struct conf * source)
118106 break ;
119107 }
120108 printf ("vhost\t\t%s\n" ,source -> relay [i ].from );
121- switch (source -> relay [i ].to_type )
109+ printf ("Address\t\t%s\n" ,source -> relay [i ].to_inet_addr );
110+ switch (source -> relay [i ].to_inet_hybridmode )
122111 {
123- case TYPE_UNIX :
124- printf ("Type \t\tUNIX Socket \n" );
125- printf ("Path\t\t%s\n" , source -> relay [ i ]. to_unix_path );
112+ case 0 :
113+ printf ("Port \t\t%d \n" , source -> relay [ i ]. to_inet_port );
114+ printf ("SRV Resolve\tDisabled\n" );
126115 break ;
127- case TYPE_INET :
128- printf ("Type\t\tInternet Socket\n" );
129- printf ("Address\t\t%s\n" ,source -> relay [i ].to_inet_addr );
130- switch (source -> relay [i ].to_inet_hybridmode )
131- {
132- case 0 :
133- printf ("Port\t\t%d\n" ,source -> relay [i ].to_inet_port );
134- printf ("SRV Resolve\tDisabled\n" );
135- break ;
136- case 1 :
137- printf ("SRV Resolve\tEnabled\n" );
138- break ;
139- }
116+ case 1 :
117+ printf ("SRV Resolve\tEnabled\n" );
140118 break ;
141119 }
142120 }
143121 if (source -> enable_default == 1 )
144122 {
145123 printf ("\n[DEFAULT RELAY]\n" );
146- switch (source -> relay_default .to_type )
124+ printf ("Address\t\t%s\n" ,source -> relay_default .to_inet_addr );
125+ switch (source -> relay_default .to_inet_hybridmode )
147126 {
148- case TYPE_UNIX :
149- printf ("Type \t\tUNIX Socket \n" );
150- printf ("Path\t%s \n" , source -> relay_default . to_unix_path );
127+ case 0 :
128+ printf ("Port \t\t%d \n" , source -> relay_default . to_inet_port );
129+ printf ("SRV Resolve\tDisabled \n" );
151130 break ;
152- case TYPE_INET :
153- printf ("Type\t\tInternet Socket\n" );
154- printf ("Address\t\t%s\n" ,source -> relay_default .to_inet_addr );
155- switch (source -> relay_default .to_inet_hybridmode )
156- {
157- case 0 :
158- printf ("Port\t\t%d\n" ,source -> relay_default .to_inet_port );
159- printf ("SRV Resolve\tDisabled\n" );
160- break ;
161- case 1 :
162- printf ("SRV Resolve\tEnabled\n" );
163- break ;
164- }
131+ case 1 :
132+ printf ("SRV Resolve\tEnabled\n" );
165133 break ;
166134 }
167135 }
@@ -245,17 +213,8 @@ int config_load(char * filename, struct conf * result)
245213 tmpptr = value ;
246214 tmpptr = strsplit (tmpptr ,':' ,key2 );
247215 tmpptr = strsplit (tmpptr ,':' ,value2 );
248- if (strcmp (key2 ,"unix" )== 0 )
249- {
250- result -> bind .type = TYPE_UNIX ;
251- strcpy (result -> bind .unix_path ,value2 );
252- }
253- else
254- {
255- result -> bind .type = TYPE_INET ;
256- strcpy (result -> bind .inet_addr ,key2 );
257- result -> bind .inet_port = basic_atosu (value2 );
258- }
216+ strcpy (result -> bind .inet_addr ,key2 );
217+ result -> bind .inet_port = basic_atosu (value2 );
259218 }
260219 else if (strcmp (key ,"proxy_pass" )== 0 )
261220 {
@@ -292,7 +251,6 @@ int config_load(char * filename, struct conf * result)
292251 }
293252 if (strsplit_fieldcount (tmpptr ,':' )== 1 )
294253 {
295- result -> relay [rec_relay ].to_type = TYPE_INET ;
296254 result -> relay [rec_relay ].to_inet_hybridmode = 1 ;
297255 tmpptr = strsplit (tmpptr ,':' ,result -> relay [rec_relay ].to_inet_addr );
298256 result -> relay [rec_relay ].to_inet_port = 25565 ;
@@ -307,26 +265,17 @@ int config_load(char * filename, struct conf * result)
307265 bzero (value2 ,sizeof (value2 ));
308266 tmpptr = strsplit (tmpptr ,':' ,key2 );
309267 tmpptr = strsplit (tmpptr ,':' ,value2 );
310- if (strcmp (key2 ,"unix" )== 0 )
268+ strcpy (result -> relay [rec_relay ].to_inet_addr ,key2 );
269+ int port = basic_atosu (value2 );
270+ if (port == 0 )
311271 {
312- result -> relay [rec_relay ].to_type = TYPE_UNIX ;
313- strcpy (result -> relay [rec_relay ].to_unix_path ,value2 );
272+ line_reccount ++ ;
273+ strcpy (tmp_buffer ,buffer [line_reccount + 1 ]);
274+ continue ;
314275 }
315276 else
316277 {
317- result -> relay [rec_relay ].to_type = TYPE_INET ;
318- strcpy (result -> relay [rec_relay ].to_inet_addr ,key2 );
319- int port = basic_atosu (value2 );
320- if (port == 0 )
321- {
322- line_reccount ++ ;
323- strcpy (tmp_buffer ,buffer [line_reccount + 1 ]);
324- continue ;
325- }
326- else
327- {
328- result -> relay [rec_relay ].to_inet_port = port ;
329- }
278+ result -> relay [rec_relay ].to_inet_port = port ;
330279 }
331280 rec_relay ++ ;
332281 line_reccount ++ ;
@@ -350,7 +299,6 @@ int config_load(char * filename, struct conf * result)
350299 if (strsplit_fieldcount (tmpptr ,':' )== 1 )
351300 {
352301 relay_default .to_inet_hybridmode = 1 ;
353- relay_default .to_type = TYPE_INET ;
354302 tmpptr = strsplit (tmpptr ,':' ,relay_default .to_inet_addr );
355303 relay_default .to_inet_port = 25565 ;
356304 }
@@ -359,24 +307,15 @@ int config_load(char * filename, struct conf * result)
359307 relay_default .to_inet_hybridmode = 0 ;
360308 tmpptr = strsplit (tmpptr ,':' ,key2 );
361309 tmpptr = strsplit (tmpptr ,':' ,value2 );
362- if (strcmp (key2 ,"unix" )== 0 )
310+ strcpy (relay_default .to_inet_addr ,key2 );
311+ int port = basic_atosu (value2 );
312+ if (port == 0 )
363313 {
364- relay_default .to_type = TYPE_UNIX ;
365- strcpy (relay_default .to_unix_path ,value2 );
314+ continue ;
366315 }
367316 else
368317 {
369- relay_default .to_type = TYPE_INET ;
370- strcpy (relay_default .to_inet_addr ,key2 );
371- int port = basic_atosu (value2 );
372- if (port == 0 )
373- {
374- continue ;
375- }
376- else
377- {
378- relay_default .to_inet_port = port ;
379- }
318+ relay_default .to_inet_port = port ;
380319 }
381320 }
382321 else
@@ -399,7 +338,7 @@ int config_load(char * filename, struct conf * result)
399338 {
400339 return CONF_ENOLOGLEVEL ;
401340 }
402- if (!((strcmp ( result -> bind . unix_path , "" ) != 0 ) || ( (strcmp (result -> bind .inet_addr ,"" )!= 0 )&& (inet_addr (result -> bind .inet_addr )!= -1 )&& (result -> bind .inet_port != 0 ))))
341+ if (!(((strcmp (result -> bind .inet_addr ,"" )!= 0 )&& (inet_addr (result -> bind .inet_addr )!= -1 )&& (result -> bind .inet_port != 0 ))))
403342 {
404343 return CONF_EINVALIDBIND ;
405344 }
0 commit comments