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
 {
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
     commandLineParser.addOption(&configOption);
41
     commandLineParser.addOption(&configOption);
42
     CommandLineOption decryptOption("decrypt", 'd', "Decrypt DATA and exit. Can be specified multiple times. Use - to read from stdin.", "DATA");
42
     CommandLineOption decryptOption("decrypt", 'd', "Decrypt DATA and exit. Can be specified multiple times. Use - to read from stdin.", "DATA");
43
     commandLineParser.addOption(&decryptOption);
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
     CommandLineOption helpOption("help", 'h', "Show this help.");
44
     CommandLineOption helpOption("help", 'h', "Show this help.");
47
     commandLineParser.addOption(&helpOption);
45
     commandLineParser.addOption(&helpOption);
48
 
46
 
63
         std::cerr << "Failed to read configuration file: " << strerror(configResult) << std::endl;
61
         std::cerr << "Failed to read configuration file: " << strerror(configResult) << std::endl;
64
         return EX_NOINPUT;
62
         return EX_NOINPUT;
65
     }
63
     }
66
-    else if (socketOption.isSet())
67
-    {
68
-        return launchMilter(socketOption.getValue());
69
-    }
70
     else if (decryptOption.isSet())
64
     else if (decryptOption.isSet())
71
     {
65
     {
72
         return launchDecrypt(decryptOption.getValues());
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
 sfsistat MainClass::mlfiHeader(SMFICTX *ctx)
74
 sfsistat MainClass::mlfiHeader(SMFICTX *ctx)
112
         Json::Value root;
108
         Json::Value root;
113
         reader.parse(stream, root);
109
         reader.parse(stream, root);
114
         _cryptoBusiness->setKey(root["key"].asString());
110
         _cryptoBusiness->setKey(root["key"].asString());
111
+        _defaultSocket = root["socket"].asString();
115
     }
112
     }
116
     return errno;
113
     return errno;
117
 }
114
 }

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

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

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

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