简体   繁体   English

服务器端Javascript函数

[英]Server-side Javascript functions

Ok guys. 好了朋友们。 I've built a web application with some friends that is somehow complex and took us some time to built. 我已经和一些朋友构建了一个Web应用程序,该应用程序有些复杂,花了我们一些时间来构建。 It is entirely built using JavaScript 它完全使用JavaScript构建

Now the application has some functions which we don't want to readily share with the world(view-source). 现在,该应用程序具有一些我们不希望与世界分享的功能(查看源代码)。

The application works by sending an input to an algorithm and receiving the output from that algorithm and displays it on a canvas. 该应用程序通过向算法发送输入并从该算法接收输出来工作并将其显示在画布上。 (Thats how all functions work anyway:) ) (这就是所有功能的工作方式:)

Okay i don't know much about node.js but from what i've heard its server-side JavaScript. 好的,我对node.js的了解不多,但是从我所听到的服务器端JavaScript的知识来看。 Does that mean that i can transfer the function server-side and using POST-GET to send an input and receive an output? 这是否意味着我可以在服务器端传输功能并使用POST-GET发送输入和接收输出? All without having the source code of that particular function readily visible to anyone? 所有这些都没有让任何人都容易看到该特定功能的源代码吗?

Please don't get started about how i should be more worried about doing things better rather than worrying about the safety of our work. 请不要开始担心我应该如何担心做得更好而不是担心我们的工作安全。 I already know that so consider my question as a complimentary safeguard, at least for the time being. 我已经知道,因此至少在目前,将我的问题视为补充保障。

Obfuscation is not a very concrete option since many developers de-obfuscate code just for fun. 混淆不是一个很具体的选择,因为许多开发人员只是出于娱乐目的而对代码进行混淆。

This application is not like a hen with a golden egg and i am not being grandiose about this, but i was just having this question in my mind for some time now so i just shoot it here to know in the future how things work. 该应用程序不像是一只金蛋母鸡,我对此并不抱有太大希望,但是我只是在脑海中浮现了这个问题一段时间,所以我只在这里拍摄一下,以了解将来的工作方式。

Thanks guys! 多谢你们!

If you're worried about protecting your ultra sweet super secret codes, you could host your app and use a little something called RPC. 如果您担心保护自己的超级甜蜜超级密码,可以托管您的应用程序并使用一些称为RPC的东西。 Remote. 远程。 Procedure. 程序。 Calls. 呼叫。

Check out this little guy 看看这个小家伙
https://github.com/deoxxa/pillion https://github.com/deoxxa/pillion

It's built on burro, a sweet package I made 它建立在我制作的甜蜜卷饼burro上
https://github.com/naomik/burro https://github.com/naomik/burro

Easy as 1-2-3 or ABC or cake or strippers or whatever else is easy 像1-2-3或ABC或蛋糕或汽提塔一样容易

% npm install pillion burro && echo omg that was so easy

DISCLAIMER 免责声明

I'm about to reveal a super secret greeting function that says hello to our clients. 我将展示一个超级秘密的greeting功能,向我们的客户问好。 This is ultra secret intellectual IP properties and should not be shared with anyone on the internets. 这是超级机密的知识产权,不应该与互联网上的任何人共享。


You could provide the function calls you need using something like this on the server 您可以在服务器上使用类似的内容提供所需的函数调用

// server.js
var net = require("net"),
    burro = require("burro"),
    pillion = require("pillion");

var server = net.createServer(function(_socket) {
  var socket = burro.wrap(_socket),
      rpc = new pillion(socket);

  rpc.provide("greet", function(name, cb) {
    cb("hi there, " + name);
  });
});

server.listen(3000);

Then on the client side 然后在客户端

// client.js
var net = require("net"),
    burro = require("burro"),
    pillion = require("pillion");

var _socket = net.connect(3000),
    socket = burro.wrap(_socket),
    rpc = new pillion(socket);

rpc.callRemote("greet", "friend", function(res) {
  console.log(res); // prints "hi there, friend"
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM