]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
--user-agent: make a global option
authorJason Ish <ish@unx.ca>
Fri, 8 Dec 2017 22:13:11 +0000 (16:13 -0600)
committerJason Ish <ish@unx.ca>
Fri, 8 Dec 2017 22:26:19 +0000 (16:26 -0600)
This allows it to apply to update-sources as well.

suricata/update/main.py

index cf00cdc3f1409aa9e39e0f0314105c752be2cafd..6437c58ead4c3cd12f66bae82e88198299277bb9 100644 (file)
@@ -937,6 +937,10 @@ def _main():
     global_parser.add_argument(
         "-c", "--config", metavar="<filename>",
         help="configuration file (default: /etc/suricata/update.yaml)")
+    global_parser.add_argument(
+        "--user-agent", metavar="<user-agent>",
+        help="Set custom user-agent string")
+
     global_args, rem = global_parser.parse_known_args()
 
     if not rem or rem[0].startswith("-"):
@@ -1011,8 +1015,6 @@ def _main():
     
     update_parser.add_argument("--no-merge", action="store_true", default=False,
                                help="Do not merge the rules into a single file")
-    update_parser.add_argument("--user-agent", metavar="<user-agent>",
-                               help="Set custom user-agent string")
 
     update_parser.add_argument("-h", "--help", action="store_true")
     
@@ -1083,6 +1085,12 @@ def _main():
     logger.debug("This is suricata-update version %s (rev: %s); Python: %s" % (
         version, revision, sys.version.replace("\n", "- ")))
 
+    # Load custom user-agent-string.
+    user_agent = config.get("user-agent")
+    if user_agent:
+        logger.info("Using user-agent: %s.", user_agent)
+        suricata.update.net.set_custom_user_agent(user_agent)
+
     if args.subcommand:
         if hasattr(args, "func"):
             return args.func()
@@ -1183,12 +1191,6 @@ def _main():
         logger.info("Loading %s.", drop_conf_filename)
         drop_filters += load_drop_filters(drop_conf_filename)
 
-    # Load custom user-agent-string
-    user_agent = config.get("user-agent")
-    if user_agent:
-        logger.info("Using user-agent: %s.",user_agent)
-        suricata.update.net.set_custom_user_agent(user_agent)
-
     if os.path.exists("/etc/suricata/suricata.yaml") and \
        suricata_path and os.path.exists(suricata_path):
         logger.info("Loading /etc/suricata/suricata.yaml")