Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

10 years ago by FelipeBudinich

With this plugin you can validate the current hostname anywhere in your code calling ig.isCurrentDomainAllowed(); (it will return a boolean), like this:


if (ig.isCurrentDomainAllowed()){
console.log('domain allowed');
} else {
console.log('domain not allowed');
}


Source code:
/*global ig*/
ig.module(
    'plugins.domain'
).requires().defines(function () {
    'use strict';
    var DomainUtils = {
            isCurrentDomainAllowed: function () {
                var allowed = ['127.0.0.1', 'www.example.com', 'example.com'],
                    isAllowed = false,
                    i;
                for (i = 0; i < allowed.length; i += 1) {
                    if (window.location.hostname === allowed[i]) {
                        isAllowed = true;
                    }
                }
                return isAllowed;
            }
        },
        methodName;

    function installFunction(name, fn) {
        if (ig[name]) {
            throw ("method " + name + "() already defined elsewhere.");
        }
        Object.defineProperty(ig, name, {
            value: fn
        });
    }
    for (methodName in DomainUtils) {
        if (DomainUtils.hasOwnProperty(methodName)) {
            installFunction(methodName, DomainUtils[methodName]);
        }
    }
});

10 years ago by Joncom

What would be an example scenario where you'd want to use something like this?

10 years ago by FelipeBudinich

Quote from Joncom
What would be an example scenario where you'd want to use something like this?


I made a simple flash game a few years back, it got some mild success and it got copied/spread around the web.

The versions hosted on kongregate, gamejolt, newgrounds, generate revenue for me, but the ones that got spread around the net, don't.

For example: I could enable a screen with advertisement every time the player loses if it is not hosted on the places that generate revenue for me, enabling me to profit from people that spread my work :)

PS: By the way, I'm aware that even if obfuscated it can be modified or removed, I just want to disuade the most casual pirates.

PS2: Also, I just had this idea of a asynchronous multiplayer game, where you could play with one faction or another depeding on the domain you used to access it.

10 years ago by Joncom

Regarding "PS", that's not a bad idea.
Regarding "PS2", that's a pretty neat idea!
If I might make one suggestion about the plugin it would be this:
Avoid hard-coding the domains in to the plugin itself.
Allow the user to configure them without modifying the plugin.
It's fine to hard-code in some defaults though, such as localhost.

9 years ago by FelipeBudinich

By the way, I've recently put the plugin to very good use, all this sites were lifting the game we released on Kongregate, and after they were indexed by google I uncommented the line were I did the domain validation, and redirected them all to Kongregate:

http://www.baixaki.com.br/jogos-online/overlod.htm http://igrigo.ru/%D0%9B%D0%BE%D0%B2%D0%BA%D0%BE%D1%81%D1%82%D1%8C/Overlod
http://spielert.de/geschick/Overlod
http://quisigioca.it/abilita/Overlod
http://jouezjeux.fr/agilite/Overlod
http://spelert.nl/behendigheid/Verzamel/Overlod
www.wfreegame.com/games-5104-overlod.html
www.gioca.re/gioco/overlod
www.gamesbutler.com/game/21444/Overlod/
http://8iz.com/game/overlod
www.plonga.com/skill/Collecting/Overlod
www.1001juegos.com/juego/overlod
http://www.crazygames.com/game/overlod

9 years ago by Apiheld

and after they were indexed by google I uncommented the line were I did the domain validation

Nice, but I'm not sure I get it: Did you include the domain check asynchronously or was the game embedded or something? How would a change in your code affect someone who ripped the entire JS code and uploaded it to their server?

9 years ago by FelipeBudinich

@Apiheld

They just used an iframe to embed the game on their site from the place I was serving it.

The code is baked so it is not that easy to spot where to modify it in order to prevent the redirection, unless you know what you are doing.

If that is the case (a knowledgeable pirate), the pirate most probably is doing his own games anyway, so he wont be wasting his time lifting other people's games :D (or if I were the pirate, I would lift easy to lift stuff)
Page 1 of 1
« first « previous next › last »