-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
136 lines (129 loc) · 6.4 KB
/
index.html
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
<!--
The MIT License (MIT)
Copyright (c) 2016 @biddster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<script type="text/javascript">
RED.nodes.registerType('ftp-server', {
category: 'input',
color: '#f37a33',
defaults: {
name: {value: ''},
ip: {value: ''},
port: {value: 7021},
passiveportrange: {
value: '',
validate: function(v) {
return /^ *([0-9]+( *- *[0-9]+)? *)?$/.test(v);
}
}
},
credentials: {
username: {type: 'text'},
password: {type: 'password'}
},
inputs: 0,
outputs: 2,
outputLabels: [
'upload file',
'authenticate'
],
icon: 'ftp.png',
label: function () {
return this.name || 'ftp server';
},
paletteLabel: 'ftp server',
align: 'left'
});
</script>
<script type="text/x-red" data-template-name="ftp-server">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-ip"><i class="icon-tag"></i>IP</label>
<input type="text" id="node-input-ip" placeholder="auto-detect">
</div>
<div class="form-row">
<label for="node-input-port"><i class="icon-tag"></i>Port</label>
<input type="number" id="node-input-port" placeholder="">
</div>
<div class="form-row">
<label for="node-input-username"><i class="icon-tag"></i>Username</label>
<input type="text" id="node-input-username" placeholder="dynamic">
</div>
<div class="form-row">
<label for="node-input-password"><i class="icon-tag"></i>Password</label>
<input type="password" id="node-input-password" placeholder="">
</div>
<div class="form-row">
<label for="node-input-passiveportrange"><i class="icon-tag"></i>Passive Mode Port Range</label>
<input type="text" id="node-input-passiveportrange" placeholder="random">
</div>
</script>
<script type="text/x-red" data-help-name="ftp-server">
<!-- START -->
<h1 id="ftp-server">FTP Server</h1>
<p>FTP Server for Node-RED that currently only supports putting files. Uploaded files are emitted from this node via<br><code>msg.payload</code> of type Buffer.</p>
<p>Written for my Dad so he can wire his IP camera's motion detection directly into Node-RED. </p>
<h1 id="installation">Installation</h1>
<pre><code>$ cd ~/.node-red
$ npm install node-red-contrib-ftp-server
</code></pre><h1 id="configure-node-red">Configure Node-RED</h1>
<p>Drag the FTP Server node into your workspace and double click to configure:</p>
<ul>
<li>Enter a free port on your Node-RED server</li>
<li>Enter a username of your choosing</li>
<li>Enter a password of your choosing</li>
</ul>
<p><img src="https://raw.githubusercontent.com/biddster/node-red-contrib-ftp-server/develop/doc/NodeRED.png" alt="NR ftp settings"></p>
<h2 id="dynamic-authentication">Dynamic authentication</h2>
<p>If you leave the username field empty the node uses the dynamic authentication mode. In this mode every login request has to be handled manually.<br>On each login attempt the node outputs an object containing the username, the password and an authenticate function on the "authenticate" output.<br>You can then manually validate the username and password and must call the authenticate function with the parameter true to accept the authentication or false to reject it.</p>
<p>Here is an example how an authenticate message would look like:</p>
<pre><code>{
payload: {
username: "username",
password: "password"
},
authenticate: <function>
}
</code></pre><p>Here is an example how to handle the login attempts in a function node:</p>
<pre><code>msg.authenticate(
msg.payload.username === 'username' &&
msg.payload.password === 'password'
);
msg.payload = undefined;
return msg;
</code></pre><h1 id="configure-a-device-to-use-your-node-red-ftp-server">Configure a device to use your Node-RED FTP server</h1>
<p>Here's an example of configuring a Foscam IP camera to upload images into Node-RED:</p>
<ul>
<li>Enter the IP address of your Node-RED server as the FTP server address</li>
<li>Enter the port, username and password that you chose when you configured the FTP node in Node-RED above.</li>
</ul>
<p>Now you can configure the motion settings of your IP camera to upload images to FTP. </p>
<p>The images are then emitted from this node as a buffer via <code>msg.payload</code>.</p>
<p><img src="https://raw.githubusercontent.com/biddster/node-red-contrib-ftp-server/develop/doc/Foscam.png" alt="Foscam ftp settings"></p>
<h3 id="enabling-extra-debugging">Enabling extra debugging</h3>
<p>Install <code>node-red-contrib-config</code> and drag a config node into your workspace. Configure the node to set a global variable called <code>ftp-server</code><br>with a JSON value of <code>{"debug": true}</code>. Also make sure that the config tickbox for <code>active</code> is unchecked. Redeploy. Now click the button on the config node.<br>This will trigger all instances of <code>ftp-server</code> to write extra logging to the os syslog next time they're invoked.</p>
<h1 id="todo">TODO</h1>
<ul>
<li>TLS support</li>
<li>Proper testing</li>
</ul>
<!-- END -->
</script>