Browse Source

moved socket from cli to conf

tags/v1.0.0^0
Robin Thoni 7 years ago
parent
commit
8ff15b915f
4 changed files with 11 additions and 10 deletions
  1. 2
    1
      milter-sasl.json
  2. 5
    8
      src/Interface/MainClass.cpp
  3. 2
    0
      src/Interface/MainClass.h
  4. 2
    1
      tests/milter-sasl.json

+ 2
- 1
milter-sasl.json View File

@@ -1,3 +1,4 @@
1 1
 {
2
-  "key": "insert your AES key here"
2
+  "key": "insert your AES key here",
3
+  "socket": "inet:4242@localhost"
3 4
 }

+ 5
- 8
src/Interface/MainClass.cpp View File

@@ -41,8 +41,6 @@ int MainClass::main()
41 41
     commandLineParser.addOption(&configOption);
42 42
     CommandLineOption decryptOption("decrypt", 'd', "Decrypt DATA and exit. Can be specified multiple times. Use - to read from stdin.", "DATA");
43 43
     commandLineParser.addOption(&decryptOption);
44
-    CommandLineOption socketOption("milter", 'm', "Launch milter and specify the socket to listen on (eg: inet:4242@localhost).", "SOCKET");
45
-    commandLineParser.addOption(&socketOption);
46 44
     CommandLineOption helpOption("help", 'h', "Show this help.");
47 45
     commandLineParser.addOption(&helpOption);
48 46
 
@@ -63,16 +61,14 @@ int MainClass::main()
63 61
         std::cerr << "Failed to read configuration file: " << strerror(configResult) << std::endl;
64 62
         return EX_NOINPUT;
65 63
     }
66
-    else if (socketOption.isSet())
67
-    {
68
-        return launchMilter(socketOption.getValue());
69
-    }
70 64
     else if (decryptOption.isSet())
71 65
     {
72 66
         return launchDecrypt(decryptOption.getValues());
73 67
     }
74
-
75
-    return commandLineParser.showHelp(EX_USAGE, true);
68
+    else
69
+    {
70
+        return launchMilter(_defaultSocket);
71
+    }
76 72
 }
77 73
 
78 74
 sfsistat MainClass::mlfiHeader(SMFICTX *ctx)
@@ -112,6 +108,7 @@ int MainClass::loadConfig(const std::string& filePath)
112 108
         Json::Value root;
113 109
         reader.parse(stream, root);
114 110
         _cryptoBusiness->setKey(root["key"].asString());
111
+        _defaultSocket = root["socket"].asString();
115 112
     }
116 113
     return errno;
117 114
 }

+ 2
- 0
src/Interface/MainClass.h View File

@@ -38,6 +38,8 @@ private:
38 38
 
39 39
     std::shared_ptr<CryptoBusiness> _cryptoBusiness;
40 40
 
41
+    std::string _defaultSocket;
42
+
41 43
     static MainClass* _instance;
42 44
 
43 45
 };

+ 2
- 1
tests/milter-sasl.json View File

@@ -1,3 +1,4 @@
1 1
 {
2
-  "key": "x%p~;mZ(A4FG]CDj"
2
+  "key": "x%p~;mZ(A4FG]CDj",
3
+  "socket": "inet:4242@localhost"
3 4
 }

Loading…
Cancel
Save