@@ -97,6 +97,7 @@ typedef enum {
97
97
oFirewallRule ,
98
98
oFirewallRuleSet ,
99
99
oTrustedMACList ,
100
+ oPopularServers ,
100
101
oHtmlMessageFile ,
101
102
oProxyPort ,
102
103
oSSLPeerVerification ,
@@ -141,6 +142,7 @@ static const struct {
141
142
"firewallruleset" , oFirewallRuleSet }, {
142
143
"firewallrule" , oFirewallRule }, {
143
144
"trustedmaclist" , oTrustedMACList }, {
145
+ "popularservers" , oPopularServers }, {
144
146
"htmlmessagefile" , oHtmlMessageFile }, {
145
147
"proxyport" , oProxyPort }, {
146
148
"sslpeerverification" , oSSLPeerVerification }, {
@@ -193,6 +195,7 @@ config_init(void)
193
195
config .internal_sock = safe_strdup (DEFAULT_INTERNAL_SOCK );
194
196
config .rulesets = NULL ;
195
197
config .trustedmaclist = NULL ;
198
+ config .popular_servers = NULL ;
196
199
config .proxy_port = 0 ;
197
200
config .ssl_certs = safe_strdup (DEFAULT_AUTHSERVSSLCERTPATH );
198
201
config .ssl_verify = DEFAULT_AUTHSERVSSLPEERVER ;
@@ -707,6 +710,9 @@ config_read(const char *filename)
707
710
case oTrustedMACList :
708
711
parse_trusted_mac_list (p1 );
709
712
break ;
713
+ case oPopularServers :
714
+ parse_popular_servers (p1 );
715
+ break ;
710
716
case oHTTPDName :
711
717
config .httpdname = safe_strdup (p1 );
712
718
break ;
@@ -889,6 +895,48 @@ parse_trusted_mac_list(const char *ptr)
889
895
890
896
}
891
897
898
+ void
899
+ parse_popular_servers (const char * ptr )
900
+ {
901
+ char * ptrcopy = NULL ;
902
+ char * hostname = NULL ;
903
+ t_popular_server * p = NULL ;
904
+
905
+ debug (LOG_DEBUG , "Parsing string [%s] for popular servers" , ptr );
906
+
907
+ // max length of domain name is 253 characters
908
+ hostname = safe_malloc (254 );
909
+
910
+ /* strsep modifies original, so let's make a copy */
911
+ ptrcopy = safe_strdup (ptr );
912
+
913
+ while ((hostname = strsep (& ptrcopy , ", " ))) {
914
+ if (strcmp (hostname , "" ) == 0 ) {
915
+ continue ;
916
+ }
917
+ debug (LOG_DEBUG , "Adding Popular Server [%s] to list" , hostname );
918
+
919
+ if (config .popular_servers == NULL ) {
920
+ config .popular_servers = safe_malloc (sizeof (t_popular_server ));
921
+ config .popular_servers -> hostname = safe_strdup (hostname );
922
+ config .popular_servers -> next = NULL ;
923
+ } else {
924
+ p = config .popular_servers ;
925
+ /* Advance to the last entry */
926
+ while (p -> next != NULL ) {
927
+ p = p -> next ;
928
+ }
929
+ p -> next = safe_malloc (sizeof (t_popular_server ));
930
+ p = p -> next ;
931
+ p -> hostname = safe_strdup (hostname );
932
+ p -> next = NULL ;
933
+ }
934
+ }
935
+
936
+ free (ptrcopy );
937
+ free (hostname );
938
+ }
939
+
892
940
/** Verifies if the configuration is complete and valid. Terminates the program if it isn't */
893
941
void
894
942
config_validate (void )
0 commit comments