A few years ago, Facebook started encouraging users to give it their phone numbers. This, it said, was only for security purposes: a way to confirm one’s login credentials. Now, as a result, anyone can look up a user’s profile via their phone number, Facebook “shares” phone numbers with its other apps (such as Instagram), and advertisers can target those numbers too. Recently, Mark Zuckerberg announced that he had developed a new “vision” for social networking that would be “privacy-focused”, and if you believe that then I have a forecast on the economic benefits of Brexit to sell you. And yet, in certain quarters of tech-savvy international relations , it’s always China that is blamed for betraying the promise of a free and open internet.

As James Griffiths’s excellent book on China’s online strategy acknowledges, that promise – the 1990s cyber-utopian vision of an anarchist, autonomous electronic frontier without borders – hardly needed an authoritarian quasi-communist state to betray it. Western corporations did perfectly well on their own. But Griffiths perhaps gives too much credence to that idealistic picture in the first place: the internet was, after all, born from military technology in the first place – the Arpanet, funded by the US Defense Department – and it’s not quite accurate to say, as he does, that it was designed without reference to geography. (The decentralised nature of the military network was precisely a geographical strategy to prevent an enemy from taking it down by destroying any particular node.)

What’s more, the filtering and censorship technology now used by China to keep its citizens behind the “great firewall” was, as he shows, eagerly supplied for years by US tech corporations, so to complain about what the Chinese have done with it – indeed, to call it, as Griffiths does rather melodramatically, “China’s war on the internet” – now is rather like selling bombs to Saudi Arabia and then wringing one’s hands when they drop them on people. Filtering and censorship capabilities were themselves built into internet hardware from the very early days. As one of the American engineers who helped network China in the 1990s tells Griffiths: “Nobody questions the authority and right of a corporation to very tightly manage and control and monitor the communications in and out of a company’s network. That tech had been built from the very beginning to serve the market of corporate customers. All China did was turn on those switches for the entire country.”

This is a sobering account of how freedom can be effectively curtailed with the tools that were supposed to liberate us

The detailed historical picture that he draws of the Chinese authorities’ approach to the online world over the last three decades is nonetheless fascinating and eye-opening. The “Great Firewall”, he explains, actually conflates two things: the filtering software installed in the three chokepoints that connect China to the rest of the internet that makes it very difficult for Chinese citizens to see forbidden websites, and the internal filtering and censorship software that automatically deletes suspicious references. It is the electronic perfection of Jeremy Bentham’s vision for a panopticon: a circular prison with a central guard-tower where, because they thought they might be watched at any time, inmates behaved well. One commentator describes China’s online thought-policing vividly as “the anaconda in the chandelier”: most of the time, it doesn’t move, but the last thing you want to do is provoke it.

Many of the stories Griffiths tells centre on dissidents and protesters such as the Falun Gong organisation and the Uighurs of Xinjiang province, and their faltering attempts to tunnel below the firewall. “China’s censors do not care about blocking content,” Griffiths asserts, “they care about blocking solidarity.” As a China specialist, he travels to Beijing, Hong Kong and elsewhere to interview brave individuals, and draws a compellingly atmospheric picture of modern arguments about control and self-determination, and even the dangerous politics of drop-down menus in web-forms. (Western companies who offer “Taiwan” as a separate residence option are bound, he shows, to incur China’s wrath.)

This is an exciting and sobering account of how freedom, which was never in the internet code in the first place, can be effectively curtailed with the tools that were supposed to liberate us. Towards the end of the book, Griffiths shows how China has in turn helped Russia with its own efforts at internet censorship, and is now exporting the same technologies to Africa. These are alarming developments, to be sure; yet at the same time western liberals increasingly demand that Twitter, Facebook, YouTube et al become censors themselves, removing certain kinds of content, and deleting the accounts of users. Griffiths quotes Xi Jinping as saying: “Cyberspace is not a domain beyond the rule of law. Greater effort should be made to strengthen ethical standards and promote civilised behaviour.” Well, it should, shouldn’t it?

• The Great Firewall of China: How to Build and Control an Alternative Version of the Internet by James Griffiths is published by Zed Books (RRP £20). To order a copy go to guardianbookshop.com. Free UK p&p on all online orders over £15.