Browse Source

webui: Fixed the issue that password modification did not take effect

Nick Peng 2 months ago
parent
commit
7c1a2325d8
4 changed files with 10 additions and 30 deletions
  1. 6 2
      package/openwrt/control/prerm
  2. 1 1
      plugin/smartdns-ui/src/plugin.rs
  3. 1 26
      src/dns_server/neighbor.c
  4. 2 1
      src/utils/daemon.c

+ 6 - 2
package/openwrt/control/prerm

@@ -20,6 +20,10 @@ default_prerm $0 $@
 /etc/init.d/smartdns disable
 rm /var/etc/smartdns.conf -f
 rm /var/etc/smartdns/smartdns.conf -f
-rm /var/log/smartdns/ -fr
-rm /etc/smartdns/smartdns.cache -f
+if [ "$1" = "remove" ]; then
+    rm /var/run/smartdns.pid -f
+    rm /var/log/smartdns/ -fr
+    rm /etc/smartdns/smartdns.cache -f
+    rm /var/lib/smartdns/ -fr
+fi
 exit 0

+ 1 - 1
plugin/smartdns-ui/src/plugin.rs

@@ -151,9 +151,9 @@ impl SmartdnsPlugin {
 
     pub fn start(&self, args: &Vec<String>) -> Result<(), Box<dyn Error>> {
         self.parser_args(args)?;
-        self.load_config()?;
         self.data_server_ctl
             .init_db(&self.data_conf.lock().unwrap())?;
+        self.load_config()?;
         self.data_server_ctl.start_data_server()?;
         let http_conf = self.http_conf.lock().unwrap().clone();
         self.http_server_ctl.start_http_server(&http_conf)?;

+ 1 - 26
src/dns_server/neighbor.c

@@ -231,36 +231,11 @@ struct dns_client_rules *_dns_server_get_client_rules_by_mac(uint8_t *netaddr, i
 	args.netaddr = netaddr;
 	args.netaddr_len = netaddr_len;
 
-	for (int i = 0; i < 2; i++) {
+	for (int i = 0; i < 1; i++) {
 		ret = netlink_get_neighbors(family, _dns_server_neighbors_callback, &args);
 		if (ret < 0) {
 			goto add_cache;
 		}
-
-		if (ret != 1) {
-			/* FIXME: ugly force refresh NDP table by sending ICMP message.*/
-			if (i == 0) {
-				char host[DNS_MAX_CNAME_LEN] = {0};
-				if (family == AF_INET) {
-					snprintf(host, sizeof(host), "%d.%d.%d.%d", netaddr[0], netaddr[1], netaddr[2], netaddr[3]);
-				} else if (family == AF_INET6) {
-					snprintf(host, sizeof(host),
-							 "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", netaddr[0],
-							 netaddr[1], netaddr[2], netaddr[3], netaddr[4], netaddr[5], netaddr[6], netaddr[7],
-							 netaddr[8], netaddr[9], netaddr[10], netaddr[11], netaddr[12], netaddr[13], netaddr[14],
-							 netaddr[15]);
-				}
-				struct ping_host_struct *ping_host = fast_ping_start(PING_TYPE_ICMP, host, 0, 10, 1000, NULL, NULL);
-				if (ping_host) {
-					/* wait for NDP*/
-					usleep(1000);
-					fast_ping_stop(ping_host);
-					continue;
-				}
-			}
-
-			goto add_cache;
-		}
 	}
 
 	if (args.group_mac == NULL) {

+ 2 - 1
src/utils/daemon.c

@@ -267,6 +267,7 @@ int create_pid_file(const char *pid_file)
 	int fd = 0;
 	int flags = 0;
 	char buff[TMP_BUFF_LEN_32];
+	int unused __attribute__((unused));
 
 	/*  create pid file, and lock this file */
 	fd = open(pid_file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
@@ -296,7 +297,7 @@ int create_pid_file(const char *pid_file)
 		goto errout;
 	}
 
-	ftruncate(fd, 0);
+	unused = ftruncate(fd, 0);
 	snprintf(buff, TMP_BUFF_LEN_32, "%d\n", getpid());
 
 	if (write(fd, buff, strnlen(buff, TMP_BUFF_LEN_32)) < 0) {