@@ -96,6 +96,7 @@ typedef enum {
96
96
oFirewallRule ,
97
97
oFirewallRuleSet ,
98
98
oTrustedMACList ,
99
+ oPopularServers ,
99
100
oHtmlMessageFile ,
100
101
oProxyPort ,
101
102
oSSLPeerVerification ,
@@ -140,6 +141,7 @@ static const struct {
140
141
"firewallruleset" , oFirewallRuleSet }, {
141
142
"firewallrule" , oFirewallRule }, {
142
143
"trustedmaclist" , oTrustedMACList }, {
144
+ "popularservers" , oPopularServers }, {
143
145
"htmlmessagefile" , oHtmlMessageFile }, {
144
146
"proxyport" , oProxyPort }, {
145
147
"sslpeerverification" , oSSLPeerVerification }, {
@@ -189,6 +191,7 @@ config_init(void)
189
191
config .internal_sock = safe_strdup (DEFAULT_INTERNAL_SOCK );
190
192
config .rulesets = NULL ;
191
193
config .trustedmaclist = NULL ;
194
+ config .popular_servers = NULL ;
192
195
config .proxy_port = 0 ;
193
196
config .ssl_certs = safe_strdup (DEFAULT_AUTHSERVSSLCERTPATH );
194
197
config .ssl_verify = DEFAULT_AUTHSERVSSLPEERVER ;
@@ -718,6 +721,9 @@ config_read(const char *filename)
718
721
case oTrustedMACList :
719
722
parse_trusted_mac_list (p1 );
720
723
break ;
724
+ case oPopularServers :
725
+ parse_popular_servers (p1 );
726
+ break ;
721
727
case oHTTPDName :
722
728
config .httpdname = safe_strdup (p1 );
723
729
break ;
@@ -900,6 +906,48 @@ parse_trusted_mac_list(const char *ptr)
900
906
901
907
}
902
908
909
+ void
910
+ parse_popular_servers (const char * ptr )
911
+ {
912
+ char * ptrcopy = NULL ;
913
+ char * hostname = NULL ;
914
+ t_popular_server * p = NULL ;
915
+
916
+ debug (LOG_DEBUG , "Parsing string [%s] for popular servers" , ptr );
917
+
918
+ // max length of domain name is 253 characters
919
+ hostname = safe_malloc (254 );
920
+
921
+ /* strsep modifies original, so let's make a copy */
922
+ ptrcopy = safe_strdup (ptr );
923
+
924
+ while ((hostname = strsep (& ptrcopy , ", " ))) {
925
+ if (strcmp (hostname , "" ) == 0 ) {
926
+ continue ;
927
+ }
928
+ debug (LOG_DEBUG , "Adding Popular Server [%s] to list" , hostname );
929
+
930
+ if (config .popular_servers == NULL ) {
931
+ config .popular_servers = safe_malloc (sizeof (t_popular_server ));
932
+ config .popular_servers -> hostname = safe_strdup (hostname );
933
+ config .popular_servers -> next = NULL ;
934
+ } else {
935
+ p = config .popular_servers ;
936
+ /* Advance to the last entry */
937
+ while (p -> next != NULL ) {
938
+ p = p -> next ;
939
+ }
940
+ p -> next = safe_malloc (sizeof (t_popular_server ));
941
+ p = p -> next ;
942
+ p -> hostname = safe_strdup (hostname );
943
+ p -> next = NULL ;
944
+ }
945
+ }
946
+
947
+ free (ptrcopy );
948
+ free (hostname );
949
+ }
950
+
903
951
/** Verifies if the configuration is complete and valid. Terminates the program if it isn't */
904
952
void
905
953
config_validate (void )
0 commit comments