Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: l2tp_manager.cc

Issue 6731015: vpn-manager: accept a hostname for remote host (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vpn-manager.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "vpn-manager/l2tp_manager.h" 5 #include "vpn-manager/l2tp_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chromeos/process.h" 10 #include "chromeos/process.h"
(...skipping 19 matching lines...) Expand all
30 using ::chromeos::ProcessImpl; 30 using ::chromeos::ProcessImpl;
31 31
32 L2tpManager::L2tpManager() 32 L2tpManager::L2tpManager()
33 : ServiceManager("l2tp"), 33 : ServiceManager("l2tp"),
34 was_initiated_(false), 34 was_initiated_(false),
35 output_fd_(-1), 35 output_fd_(-1),
36 ppp_interface_path_(kPppInterfacePath), 36 ppp_interface_path_(kPppInterfacePath),
37 l2tpd_(new ProcessImpl) { 37 l2tpd_(new ProcessImpl) {
38 } 38 }
39 39
40 bool L2tpManager::Initialize(const std::string& remote_address) { 40 bool L2tpManager::Initialize(const std::string& remote_host) {
41 remote_address_ = remote_address; 41 remote_host_ = remote_host;
42 if (FLAGS_user.empty()) { 42 if (FLAGS_user.empty()) {
43 LOG(ERROR) << "l2tp layer requires user name"; 43 LOG(ERROR) << "l2tp layer requires user name";
44 return false; 44 return false;
45 } 45 }
46 if (!FLAGS_pppd_plugin.empty() && 46 if (!FLAGS_pppd_plugin.empty() &&
47 !file_util::PathExists(FilePath(FLAGS_pppd_plugin))) { 47 !file_util::PathExists(FilePath(FLAGS_pppd_plugin))) {
48 LOG(WARNING) << "pppd_plugin (" << FLAGS_pppd_plugin << ") does not exist"; 48 LOG(WARNING) << "pppd_plugin (" << FLAGS_pppd_plugin << ") does not exist";
49 } 49 }
50 if (!FLAGS_password.empty()) { 50 if (!FLAGS_password.empty()) {
51 LOG(WARNING) << "Passing a password on the command-line is insecure"; 51 LOG(WARNING) << "Passing a password on the command-line is insecure";
52 } 52 }
53 return true; 53 return true;
54 } 54 }
55 55
56 static void AddString(std::string* config, const char* key, 56 static void AddString(std::string* config, const char* key,
57 const std::string& value) { 57 const std::string& value) {
58 config->append(StringPrintf("%s = %s\n", key, value.c_str())); 58 config->append(StringPrintf("%s = %s\n", key, value.c_str()));
59 } 59 }
60 60
61 static void AddBool(std::string* config, const char* key, bool value) { 61 static void AddBool(std::string* config, const char* key, bool value) {
62 config->append(StringPrintf("%s = %s\n", key, value ? "yes" : "no")); 62 config->append(StringPrintf("%s = %s\n", key, value ? "yes" : "no"));
63 } 63 }
64 64
65 std::string L2tpManager::FormatL2tpdConfiguration( 65 std::string L2tpManager::FormatL2tpdConfiguration(
66 const std::string& ppp_config_path) { 66 const std::string& ppp_config_path) {
67 std::string l2tpd_config; 67 std::string l2tpd_config;
68 l2tpd_config.append(StringPrintf("[lac %s]\n", kL2tpConnectionName)); 68 l2tpd_config.append(StringPrintf("[lac %s]\n", kL2tpConnectionName));
69 AddString(&l2tpd_config, "lns", remote_address_); 69 AddString(&l2tpd_config, "lns", remote_host_);
70 AddBool(&l2tpd_config, "require chap", FLAGS_require_chap); 70 AddBool(&l2tpd_config, "require chap", FLAGS_require_chap);
71 AddBool(&l2tpd_config, "refuse pap", FLAGS_refuse_pap); 71 AddBool(&l2tpd_config, "refuse pap", FLAGS_refuse_pap);
72 AddBool(&l2tpd_config, "require authentication", 72 AddBool(&l2tpd_config, "require authentication",
73 FLAGS_require_authentication); 73 FLAGS_require_authentication);
74 AddString(&l2tpd_config, "name", FLAGS_user); 74 AddString(&l2tpd_config, "name", FLAGS_user);
75 AddBool(&l2tpd_config, "ppp debug", FLAGS_ppp_debug); 75 AddBool(&l2tpd_config, "ppp debug", FLAGS_ppp_debug);
76 AddString(&l2tpd_config, "pppoptfile", ppp_config_path); 76 AddString(&l2tpd_config, "pppoptfile", ppp_config_path);
77 AddBool(&l2tpd_config, "length bit", FLAGS_length_bit); 77 AddBool(&l2tpd_config, "length bit", FLAGS_length_bit);
78 return l2tpd_config; 78 return l2tpd_config;
79 } 79 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return pid == l2tpd_->pid(); 205 return pid == l2tpd_->pid();
206 } 206 }
207 207
208 void L2tpManager::Stop() { 208 void L2tpManager::Stop() {
209 if (l2tpd_->pid()) { 209 if (l2tpd_->pid()) {
210 LOG(INFO) << "Shutting down L2TP"; 210 LOG(INFO) << "Shutting down L2TP";
211 Terminate(); 211 Terminate();
212 } 212 }
213 OnStopped(false); 213 OnStopped(false);
214 } 214 }
OLDNEW
« ipsec_manager.cc ('K') | « l2tp_manager.h ('k') | l2tp_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698