/* Step: File sharing Turns on the file servers that let other computers open the drives over the network: Windows file sharing (the built-in SMB server, or Samba when that is what the host has), WebDAV and SFTP. Switches apply at once, through the same endpoints as System Settings > File Servers. The built-in SMB server needs a separate SMB password per person (NTLM cannot use the login hash), so turning it on also asks the admin for theirs, confirmed with their login password. */ (function () { "use strict"; var W = window.Wizard, T = W.T, esc = W.esc; var SERVERS = { smb: { icon: "windows", title: function () { return T("share/smb", "Windows file sharing (SMB)"); }, desc: function () { return T("share/smb/desc", "Open the server in Windows Explorer or the macOS Finder like any network drive. This server is still experimental."); } }, smbd: { icon: "windows", title: function () { return T("share/samba", "Windows file sharing (Samba)"); }, desc: function () { return T("share/samba/desc", "Share drives through Samba. Each person sets a Samba password in System Settings > File Servers."); } }, webdav: { icon: "globe", title: function () { return "WebDAV"; }, desc: function () { return T("share/webdav/desc", "For file managers, phones and sync apps that support WebDAV. Uses the same address as this page."); } }, sftp: { icon: "terminal", title: function () { return "SFTP"; }, desc: function () { return T("share/sftp/desc", "Secure transfers with apps such as FileZilla or WinSCP."); } } }; var ORDER = ["smb", "smbd", "webdav", "sftp"]; function offered() { var list = []; ORDER.forEach(function (id) { W.state.fileServers.forEach(function (s) { if (s.id === id) { list.push(s); } }); }); //The built-in SMB server and Samba both take port 445: offer one if (list.some(function (s) { return s.id === "smb"; })) { list = list.filter(function (s) { return s.id !== "smbd"; }); } return list; } function addressOf(ep) { var host = window.location.hostname; if (ep.ProtocolName === "smb://") { return ep.Port ? "smb://" + host + ":" + ep.Port : "\\\\" + host; } return ep.ProtocolName + host + (ep.Port ? ":" + ep.Port : "") + (ep.Subpath || ""); } function showAddress($card, id) { var $addr = $card.find("[data-address]"); W.api("GET", "system/network/server/endpoints?fserv=" + encodeURIComponent(id)).then(function (eps) { if (!Array.isArray(eps) || eps.length === 0) { $addr.empty(); return; } $addr.html(esc(T("share/address", "Address")) + ': ' + esc(addressOf(eps[0])) + ""); }, function () { $addr.empty(); }); } function setEnabled(server, on) { return W.api("POST", "system/network/server/toggle", { id: server.id, enable: on ? "true" : "false" }).then(function () { server.enabled = on; W.progress.sharing[server.id] = on; W.save(); }); } //The SMB password panel of the built-in server function smbPanel($card, server) { var $panel = $card.find("[data-panel]"); W.api("GET", "system/storage/smb/status").then(function (status) { var activated = status && status.Activated; //An admin may have lifted the 8 character minimum; the server then checks alone var strict = !status || !status.MinPasswordLength || status.MinPasswordLength >= 8; $panel.removeClass("wz-hidden").html( '
' + esc(T("share/lead", "Turn on the ways your computers and phones can reach this server over your network. Everyone signs in with their own account and sees only the drives they may use.")) + "
" + '