Thread: [srvx-commits] CVS: services/src hash.c,1.176,1.177 hash.h,1.103,1.104 opserv.c,1.320,1.321 opserv.h
                
                Brought to you by:
                
                    entrope
                    
                
            
            
        
        
        
    | 
      
      
      From: Entrope <en...@us...> - 2003-07-12 02:59:53
       | 
| Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv31730/src
Modified Files:
	hash.c hash.h opserv.c opserv.help proto-bahamut.c proto-p10.c 
	proto.h 
Log Message:
implement channel alerts
implement a true-time-resync version of ?settime
Index: hash.c
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.c,v
retrieving revision 1.176
retrieving revision 1.177
diff -C2 -r1.176 -r1.177
*** hash.c	7 Jul 2003 16:29:33 -0000	1.176
--- hash.c	12 Jul 2003 02:59:49 -0000	1.177
***************
*** 417,421 ****
  }
  
! void
  DelChannel(struct chanNode *channel)
  {
--- 417,421 ----
  }
  
! static void
  DelChannel(struct chanNode *channel)
  {
***************
*** 425,430 ****
      dict_remove(channels, channel->name);
  
!     if (channel->members.used) {
!         log_module(MAIN_LOG, LOG_ERROR, "Warning: deleting channel %s with %d users remaining.", channel->name, channel->members.used);
      }
  
--- 425,430 ----
      dict_remove(channels, channel->name);
  
!     if (channel->members.used || channel->locks) {
!         log_module(MAIN_LOG, LOG_ERROR, "Warning: deleting channel %s with %d users and %d locks remaining.", channel->name, channel->members.used, channel->locks);
      }
  
***************
*** 518,521 ****
--- 518,534 ----
  
  void
+ LockChannel(struct chanNode* channel)
+ {
+     channel->locks++;
+ }
+ 
+ void
+ UnlockChannel(struct chanNode *channel)
+ {
+     if (!channel->locks) return;
+     if (!--channel->locks && !channel->members.used) DelChannel(channel);
+ }
+ 
+ void
  DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reason, int deleting)
  {
***************
*** 539,543 ****
      for (n=0; n<pf_used; n++) pf_list[n](user, channel, reason);
  
!     if (!deleting && !channel->members.used) DelChannel(channel);
  }
  
--- 552,558 ----
      for (n=0; n<pf_used; n++) pf_list[n](user, channel, reason);
  
!     if (!deleting && !channel->members.used && !channel->locks) {
!         DelChannel(channel);
!     }
  }
  
Index: hash.h
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -C2 -r1.103 -r1.104
*** hash.h	8 Jul 2003 01:17:50 -0000	1.103
--- hash.h	12 Jul 2003 02:59:49 -0000	1.104
***************
*** 122,126 ****
    char name[CHANNELLEN + 1];
    chan_mode_t modes;
!   unsigned int limit;
    char key[KEYLEN + 1];
    time_t timestamp; /* creation time */
--- 122,126 ----
    char name[CHANNELLEN + 1];
    chan_mode_t modes;
!   unsigned int limit, locks;
    char key[KEYLEN + 1];
    time_t timestamp; /* creation time */
***************
*** 149,153 ****
      struct chanNode *channel;
      struct userNode *user;
!     long modes;	
      time_t idle_since;
  };
--- 149,153 ----
      struct chanNode *channel;
      struct userNode *user;
!     long modes;
      time_t idle_since;
  };
***************
*** 215,219 ****
  
  struct chanNode* AddChannel(const char *name, time_t time_, const char *modes, char *banlist);
! void DelChannel(struct chanNode* channel);
  
  struct modeNode* AddChannelUser(struct userNode* user, struct chanNode* channel);
--- 215,220 ----
  
  struct chanNode* AddChannel(const char *name, time_t time_, const char *modes, char *banlist);
! void LockChannel(struct chanNode *channel);
! void UnlockChannel(struct chanNode *channel);
  
  struct modeNode* AddChannelUser(struct userNode* user, struct chanNode* channel);
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.320
retrieving revision 1.321
diff -C2 -r1.320 -r1.321
*** opserv.c	8 Jul 2003 03:41:57 -0000	1.320
--- opserv.c	12 Jul 2003 02:59:49 -0000	1.321
***************
*** 265,268 ****
--- 265,269 ----
  static dict_t opserv_user_alerts; /* data is struct opserv_user_alert* */
  static dict_t opserv_nick_based_alerts; /* data is struct opserv_user_alert* */
+ static dict_t opserv_channel_alerts; /* data is struct opserv_user_alert* */
  static struct module *opserv_module;
  static struct service *opserv_service;
***************
*** 357,360 ****
--- 358,362 ----
  {
      struct opserv_user_alert *alert = data;
+     if (alert->discrim->channel) UnlockChannel(alert->discrim->channel);
      free(alert->owner);
      free(alert->text_discrim);
***************
*** 1869,1872 ****
--- 1871,1876 ----
      if (IsService(user)) return 0;
  
+     dict_foreach(opserv_channel_alerts, alert_check_user, user);
+ 
      if (channel->bad_channel) {
          opserv_debug(OSMSG_ILLEGAL_CHANNEL_USER, user->nick, channel->name);
***************
*** 2482,2486 ****
      alert->reaction = reaction;
      dict_insert(opserv_user_alerts, name_dup, alert);
!     if (alert->discrim->mask_nick) dict_insert(opserv_nick_based_alerts, name_dup, alert);
      return alert;
  }
--- 2486,2491 ----
      alert->reaction = reaction;
      dict_insert(opserv_user_alerts, name_dup, alert);
!     if (alert->discrim->channel) dict_insert(opserv_channel_alerts, name_dup, alert);
!     else if (alert->discrim->mask_nick) dict_insert(opserv_nick_based_alerts, name_dup, alert);
      return alert;
  }
***************
*** 2823,2828 ****
  {
      const char *srv_name_mask = "*";
      if (argc > 1) srv_name_mask = argv[1];
!     irc_settime(srv_name_mask);
      reply(OSMSG_SETTIME_SUCCESS, srv_name_mask);
      return 1;
--- 2828,2836 ----
  {
      const char *srv_name_mask = "*";
+     time_t new_time = now;
+ 
      if (argc > 1) srv_name_mask = argv[1];
!     if (argc > 2) new_time = time(NULL);
!     irc_settime(srv_name_mask, new_time);
      reply(OSMSG_SETTIME_SUCCESS, srv_name_mask);
      return 1;
***************
*** 2880,2889 ****
              discrim->duration = ParseInterval(argv[++i]);
  	} else if (irccasecmp(argv[i], "channel") == 0) {
!             if (!allow_channel) {
!                 opserv_notice(user, OSMSG_TRACE_NO_CHANNEL);
!                 goto fail;
!             }
!             i++;
!             for (j=0; ; j++) {
                  switch (argv[i][j]) {
                  case '#':
--- 2888,2892 ----
              discrim->duration = ParseInterval(argv[++i]);
  	} else if (irccasecmp(argv[i], "channel") == 0) {
!             for (j=0, i++; ; j++) {
                  switch (argv[i][j]) {
                  case '#':
***************
*** 2907,2912 ****
              discrim->chan_no_modes &= ~discrim->chan_req_modes;
  	    if (!(discrim->channel = GetChannel(argv[i]+j))) {
! 		opserv_notice(user, MSG_CHANNEL_UNKNOWN, argv[i]);
! 		goto fail;
  	    }
          } else if (irccasecmp(argv[i], "numchannels") == 0) {
--- 2910,2922 ----
              discrim->chan_no_modes &= ~discrim->chan_req_modes;
  	    if (!(discrim->channel = GetChannel(argv[i]+j))) {
!                 /* secretly "allow_channel" now means "if a channel name is
!                  * specified, require that it currently exist" */
!                 if (allow_channel) {
!                     opserv_notice(user, MSG_CHANNEL_UNKNOWN, argv[i]);
!                     goto fail;
!                 } else {
!                     discrim->channel = AddChannel(argv[i]+j, now, NULL, NULL);
!                 }
!                 LockChannel(discrim->channel);
  	    }
          } else if (irccasecmp(argv[i], "numchannels") == 0) {
***************
*** 3296,3299 ****
--- 3306,3310 ----
      }
  
+     if (das.discrim->channel) UnlockChannel(das.discrim->channel);
      free(das.discrim->reason);
      free(das.discrim);
***************
*** 3799,3802 ****
--- 3810,3814 ----
      for (i=1; i<argc; i++) {
          dict_remove(opserv_nick_based_alerts, argv[i]);
+         dict_remove(opserv_channel_alerts, argv[i]);
  	if (dict_remove(opserv_user_alerts, argv[i])) {
  	    opserv_notice(user, OSMSG_REMOVED_ALERT, argv[i]);
***************
*** 3902,3905 ****
--- 3914,3919 ----
      dict_set_free_data(opserv_chan_warn, free);
      /* set up opserv_user_alerts */
+     dict_delete(opserv_channel_alerts);
+     opserv_channel_alerts = dict_new();
      dict_delete(opserv_nick_based_alerts);
      opserv_nick_based_alerts = dict_new();
***************
*** 3929,3934 ****
      unreg_del_user_func(opserv_user_cleanup);
      dict_delete(opserv_hostinfo_dict);
-     dict_delete(opserv_user_alerts);
      dict_delete(opserv_nick_based_alerts);
      for (nn=0; nn<ArrayLength(level_strings); ++nn) {
          if (level_strings[nn]) free(level_strings[nn]);
--- 3943,3949 ----
      unreg_del_user_func(opserv_user_cleanup);
      dict_delete(opserv_hostinfo_dict);
      dict_delete(opserv_nick_based_alerts);
+     dict_delete(opserv_channel_alerts);
+     dict_delete(opserv_user_alerts);
      for (nn=0; nn<ArrayLength(level_strings); ++nn) {
          if (level_strings[nn]) free(level_strings[nn]);
Index: opserv.help
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.help,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -r1.60 -r1.61
*** opserv.help	12 Jul 2003 01:43:18 -0000	1.60
--- opserv.help	12 Jul 2003 02:59:50 -0000	1.61
***************
*** 393,399 ****
          "Dumps a raw server message into the stream. Unlike $bdump$b, $braw$b does $bNOT$b check line syntax before sending it, making $braw$b dangerous. It will however, after the line is sent, warn of a parse error if there is a problem with the line. It is $bHIGHLY$b recommended that $bdump$b be used instead of $braw$b because it is much safer.",
          "$uSee Also:$u dump");
! "SETTIME" ("/msg $O SETTIME [servermask]",
          "Sets the time on the named server(s) to match the time known to srvx.",
!         "For example, using $b*$b as the mask sets the time on all servers; using a server's full name sets the time only on that one.");
  "STATS" ("/msg $O STATS <subject>",
          "Displays statistics about a specified subject. Subjects include:",
--- 393,400 ----
          "Dumps a raw server message into the stream. Unlike $bdump$b, $braw$b does $bNOT$b check line syntax before sending it, making $braw$b dangerous. It will however, after the line is sent, warn of a parse error if there is a problem with the line. It is $bHIGHLY$b recommended that $bdump$b be used instead of $braw$b because it is much safer.",
          "$uSee Also:$u dump");
! "SETTIME" ("/msg $O SETTIME [servermask] [resync]",
          "Sets the time on the named server(s) to match the time known to srvx.",
!         "For example, using $b*$b as the mask sets the time on all servers; using a server's full name sets the time only on that one.",
!         "If the RESYNC argument is provided, sets the time to what srvx believes the local time is, rather than what it believes the network time is.");
  "STATS" ("/msg $O STATS <subject>",
          "Displays statistics about a specified subject. Subjects include:",
Index: proto-bahamut.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-bahamut.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** proto-bahamut.c	7 Jul 2003 16:29:33 -0000	1.37
--- proto-bahamut.c	12 Jul 2003 02:59:50 -0000	1.38
***************
*** 444,448 ****
  
  void
! irc_settime(const char *srv_name_mask)
  {
      /* Bahamut has nothing like this, so ignore it. */
--- 444,448 ----
  
  void
! irc_settime(const char *srv_name_mask, time_t new_time)
  {
      /* Bahamut has nothing like this, so ignore it. */
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -r1.66 -r1.67
*** proto-p10.c	7 Jul 2003 16:29:33 -0000	1.66
--- proto-p10.c	12 Jul 2003 02:59:50 -0000	1.67
***************
*** 522,529 ****
  
  void
! irc_settime(const char *srv_name_mask)
  {
      putsock("%s " P10_SETTIME " " FMT_TIME_T " %s",
!             self->numeric, now, srv_name_mask);
  }
  
--- 522,530 ----
  
  void
! irc_settime(const char *srv_name_mask, time_t new_time)
  {
+     clock_skew = new_time - time(NULL);
      putsock("%s " P10_SETTIME " " FMT_TIME_T " %s",
!             self->numeric, new_time, srv_name_mask);
  }
  
Index: proto.h
===================================================================
RCS file: /cvsroot/srvx/services/src/proto.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -r1.74 -r1.75
*** proto.h	8 Jul 2003 01:17:51 -0000	1.74
--- proto.h	12 Jul 2003 02:59:50 -0000	1.75
***************
*** 144,148 ****
  /* network maintenance */
  void irc_gline(struct server *srv, struct gline *gline);
! void irc_settime(const char *srv_name_mask);
  void irc_ungline(const char *mask);
  void irc_error(const char *to, const char *message);
--- 144,148 ----
  /* network maintenance */
  void irc_gline(struct server *srv, struct gline *gline);
! void irc_settime(const char *srv_name_mask, time_t new_time);
  void irc_ungline(const char *mask);
  void irc_error(const char *to, const char *message);
 |