1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
--- a/conf/Makefile
+++ b/conf/Makefile
@@ -34,15 +34,15 @@ tspc.conf.sample:
fi
@if [ -z "$(configdir)" ]; then \
if [ -z "$(installdir)" ]; then \
- sed -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+`cd ..;pwd`+" tspc.conf.in>$(BIN)/tspc.conf.sample; \
+ $(SED) -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+`cd ..;pwd`+" tspc.conf.in>$(BIN)/tspc.conf.sample; \
else \
- sed -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(installdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
+ $(SED) -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(installdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
fi \
else \
- sed -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(configdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
+ $(SED) -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(configdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
fi
- chmod 700 $(BIN)/tspc.conf.sample
+ chmod 600 $(BIN)/tspc.conf.sample
clean:
--- a/conf/tspc.conf.in
+++ b/conf/tspc.conf.in
@@ -18,13 +18,6 @@
# to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#------------------------------------------------------------------------------
-#
-#
-# tsp directory:
-# the only use is for the OS scripts which will be taken
-# from $tsp_dir/template
-#
-tsp_dir=@tsp_dir@
#
# authentication method:
@@ -66,28 +59,19 @@ passwd=
#
# Name of the script:
-# template=checktunnel|freebsd|netbsd|linux|windows|darwin|cisco|
-# solaris|openbsd
+# template=checktunnel|setup
#
# the value is the file name of the script in the tsp_dir/template directory
# The script will be executed after the TSP session is completed. The script
# is configuring the tunnel interface and routes.
# checktunnel is only printing information and does not configure any tunnel
-# freebsd is for FreeBSD 4.X and above
-# netbsd is for NetBSD 1.6 and above
-# linux is for Linux (most distributions)
-# windows is for WindowsXP
-# darwin is for MacOS X 10.2 and above
-# cisco is for Cisco IOS. This script prints the cisco configuration while
-# not configuring the cisco itself.
-# solaris is for Solaris 8 and above.
-# openbsd is for OpenBSD 3.X and above
+# setup will do the actual work
# you could customize your own script, name it and put the filename in
# the template variable.
# on unix, '.sh' is added to the name of the script.
# on windows, '.bat' is added to the name of the script.
#
-template=@target@
+template=setup
#
# 'server' is the tunnel broker identifier
--- a/platform/linux/tsp_local.c
+++ b/platform/linux/tsp_local.c
@@ -59,13 +59,13 @@
/* these globals are defined by US used by alot of things in */
-char *FileName = "tspc.conf";
-char *LogFile = "tspc.log";
+char *FileName = "/etc/tsp/tspc.conf";
+char *LogFile = "/var/log/tspc.log";
char *LogFileName = NULL;
-char *ScriptInterpretor = "/bin/sh";
+char *ScriptInterpretor = "";
char *ScriptExtension = "sh";
char *ScriptDir = NULL;
-char *TspHomeDir = "/usr/local/etc/tsp";
+char *TspHomeDir = "/etc/tsp";
char DirSeparator = '/';
int Verbose = 0;
@@ -143,7 +143,7 @@ int tspStartLocal(SOCKET socket, tConf *
{
int tunfd;
- Display(0, ELInfo, "tspStartLocal", "Going daemon, check %s for tunnel creation status", LogFile);
+ Display(1, ELInfo, "tspStartLocal", "Going daemon, check %s for tunnel creation status", LogFile);
if (daemon(0,0) == -1) {
Display(1, ELError, "tspStartLocal", "Unable to fork.");
--- a/src/lib/config.c
+++ b/src/lib/config.c
@@ -474,14 +474,17 @@ int tspVerifyConfig(tConf *Conf)
if(IsPresent(Conf->dns_server)) {
char *Server;
char *dns = strdup(Conf->dns_server);
+ struct addrinfo *contact;
if (eq(Conf->host_type, "host")) {
Display(1,ELError, "tspVerifyConfig", "DNS delegation is not supported for host_type=host");
status = 1;
}
for(Server = strtok(dns, ":");Server; Server = strtok(NULL, ":")) {
- if(gethostbyname(Server) == NULL) {
+ if(getaddrinfo(Server, "domain", 0, &contact)!=0) {
Display(1,ELError, "tspVerifyConfig", "DNS server name %s is not resolving.", Server);
status = 1;
+ } else {
+ freeaddrinfo(contact);
}
}
free(dns);
--- a/src/tsp/tsp_client.c
+++ b/src/tsp/tsp_client.c
@@ -275,7 +275,7 @@ int tspSetupTunnel(tConf *conf, net_tool
start_show:
- Display(0, ELInfo, "tspSetupTunnel", "Got tunnel parameters from server, setting up local tunnel");
+ Display(1, ELInfo, "tspSetupTunnel", "Got tunnel parameters from server, setting up local tunnel");
/* and start the show */
ret = tspStartLocal(socket, conf, &t, nt[conf->transport]);
@@ -337,8 +337,8 @@ int tspMain(int argc, char *argv[])
LogInit("tspc", LogFile);
Display( 1, ELInfo, "tspMain", "----- TSP Client Version %s Initializing -------------------------", TSP_CLIENT_VERSION);
- Display( 0, ELInfo, "tspMain", IDENTIFICATION);
- Display( 0, ELInfo, "tspMain", "Initializing (use -h for help)\n");
+ Display( 1, ELInfo, "tspMain", IDENTIFICATION);
+ Display( 1, ELInfo, "tspMain", "Initializing (use -h for help)\n");
if((status = tspInitialize(argc, argv, &c)) != 0) { // *** we have no uninitialize
if (status == -1) {
@@ -361,12 +361,12 @@ int tspMain(int argc, char *argv[])
/* first try with RUDP */
c.transport = NET_TOOLS_T_RUDP;
- Display( 0, ELInfo, "tspMain", "\nConnecting to server with reliable udp");
+ Display( 1, ELInfo, "tspMain", "\nConnecting to server with reliable udp");
try_server:
if (c.transport == NET_TOOLS_T_TCP)
- Display( 0, ELInfo, "tspMain", "\nConnecting to server with tcp");
+ Display( 1, ELInfo, "tspMain", "\nConnecting to server with tcp");
Display( 1, ELInfo, "tspMain", "Using TSP protocol version %s",
TspProtocolVersionStrings[version_index]);
--- a/template/linux.sh
+++ b/template/linux.sh
@@ -135,9 +135,7 @@ if [ X"${TSP_HOST_TYPE}" = X"host" ] ||
#
# Default route
Display 1 "Adding default route"
- ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete old gw route
- Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
fi
@@ -147,9 +145,10 @@ if [ X"${TSP_HOST_TYPE}" = X"router" ];
Display 1 "Kernel setup"
if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
#Better way on linux to avoid loop with the remaining /48?
- $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE 2>/dev/null
+ ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE 2>/dev/null
+ Exec $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE
fi
- Exec $sysctl -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
+ Exec $sysctl -q -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
if [ ! -z $OLDADDR ]; then
@@ -157,28 +156,28 @@ if [ X"${TSP_HOST_TYPE}" = X"router" ];
Exec $ifconfig $TSP_HOME_INTERFACE inet6 del $OLDADDR
fi
Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
- # Router advertisement configuration
- Display 1 "Create new $rtadvdconfigfile"
- echo "##### rtadvd.conf made by TSP ####" > "$rtadvdconfigfile"
- echo "interface $TSP_HOME_INTERFACE" >> "$rtadvdconfigfile"
- echo "{" >> "$rtadvdconfigfile"
- echo " AdvSendAdvert on;" >> "$rtadvdconfigfile"
- echo " prefix $TSP_PREFIX::/64" >> "$rtadvdconfigfile"
- echo " {" >> "$rtadvdconfigfile"
- echo " AdvOnLink on;" >> "$rtadvdconfigfile"
- echo " AdvAutonomous on;" >> "$rtadvdconfigfile"
- echo " };" >> "$rtadvdconfigfile"
- echo "};" >> "$rtadvdconfigfile"
- echo "" >> "$rtadvdconfigfile"
- /etc/init.d/radvd stop
- if [ -f $rtadvdconfigfile ]; then
- KillProcess $rtadvdconfigfile
- Exec $rtadvd -u radvd -C $rtadvdconfigfile
- Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
- else
- echo "Error : file $rtadvdconfigfile not found"
- exit 1
- fi
+# # Router advertisement configuration
+# Display 1 "Create new $rtadvdconfigfile"
+# echo "##### rtadvd.conf made by TSP ####" > "$rtadvdconfigfile"
+# echo "interface $TSP_HOME_INTERFACE" >> "$rtadvdconfigfile"
+# echo "{" >> "$rtadvdconfigfile"
+# echo " AdvSendAdvert on;" >> "$rtadvdconfigfile"
+# echo " prefix $TSP_PREFIX::/64" >> "$rtadvdconfigfile"
+# echo " {" >> "$rtadvdconfigfile"
+# echo " AdvOnLink on;" >> "$rtadvdconfigfile"
+# echo " AdvAutonomous on;" >> "$rtadvdconfigfile"
+# echo " };" >> "$rtadvdconfigfile"
+# echo "};" >> "$rtadvdconfigfile"
+# echo "" >> "$rtadvdconfigfile"
+# /etc/init.d/radvd stop
+# if [ -f $rtadvdconfigfile ]; then
+# KillProcess $rtadvdconfigfile
+# Exec $rtadvd -u radvd -C $rtadvdconfigfile
+# Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
+# else
+# echo "Error : file $rtadvdconfigfile not found"
+# exit 1
+# fi
fi
Display 1 "--- End of configuration script. ---"
|