A dozen or so years ago the internet was hailed as the perfect tool to bring down dictatorships, build democracy and prosperity, and interconnect the world. But cyberpessimism has replaced cyberoptimism. Now we fear that the ’net and social media are doing just the opposite.

Democracy is declining globally. Some worry that the current wave of authoritarian regimes, led by China, build cybercontrols that could achieve near-perfection. China’s massive, sophisticated, ferocious and effective Great Firewall nullifies any online regime opposition before it starts. China’s control of social media by armies of censors and algorithms chokes off collective action such as protests or strikes.

Such is the message of a new book by a CNN journalist in Hong Kong, James Griffiths’ “The Great Firewall of China.” For some years, clever techniques circumvented the Firewall, but they are now blocked in a permanent cat-and-mouse game that the cat always wins. Weibo briefly carried citizen criticism, but it was snipped off by 2013 around the time Xi Jinping took power.

Chinese censors can take offline at a whim suspicious individuals, messages, blogs or whole provinces. Originators and bloggers self-censor or face arrest. Especially Uyghur and Tibetan sites are blocked. China also disconnects from the global internet in favor of Chinese platforms, techniques Russia and several African countries have adopted.

In 2010, while lecturing in China, I read in The New York Times online about a young drunken driver who hit two women students on a Chinese campus. He exclaimed, “My father is Li Gang!,” a local police chief, as if that would prevent his arrest. Official Chinese news outlets were silent, but students quickly put the incident online, where it went viral nationwide. Picked up by The Times’ Beijing bureau, The Times ran the story worldwide, embarrassing Beijing.

I doubt that could happen again. First, censors quickly delete negative online incidents. Second, The New York Times, even in English, is generally blocked from Chinese readers. The Chinese-language Times was entirely blocked within a few months of its 2012 start in retaliation for reporting the egregious wealth of the premier’s family.

China propounds a doctrine of “cybersovereignty,” and Russia and other countries are following its lead. In 2011, Evgeny Morozov in his book “Net Delusion” predicted that control of the internet is easy and that soon authoritarian regimes would do it. Controversial at the time, he has been proven right. Internet abuse pushes even free countries, including the U.S., toward greater control.

Now, link this discussion of cybercontol to Robert Kagan’s recent Washington Post op-ed on the growth of authoritarianism. Disputing the conventional wisdom that ideology is dead, Kagan argues that authoritarianism poses a new ideological challenge.

China’s semi-Maoism, Russia’s mafia-state, Iran’s theocracy, Turkey’s neo-Ottomanism and Hungary’s “illiberal democracy” espouse no common ideology — but they all hate and squelch liberal democracy. Moscow and Beijing elites, by dint of their training, harbor residual Marxism, namely, their conviction that capitalism is doomed, which, they suppose, the 2008 financial meltdown demonstrated. (It didn’t.)

It really boils down to liberal versus non-liberal systems, argues Kagan. And the two will not live in peace with each other. Note how all of the above, despite their differences, make common cause — against us.

The new authoritarians propound hefty and not undeserved critiques of liberal democracy. It is factionalized into paralysis that cannot even pass a budget or decide to leave the European Union. We are not paralyzed, proclaim the authoritarians; we make decisions and implement them. We provide the embrace of nationalism that individualistic liberalism cannot. We are the wave of the future (sounds like the 1930s).

Artificial intelligence (AI) strengthens authoritarianism. China is implementing a facial-recognition program to track 1.4 billion Chinese. Obedient citizens will be rewarded with “social credit”; those who deviate will lose. This surveillance state easily leads to what Kagan calls the “perfection of dictatorship.” Big Brother will really be watching.

Dictatorships, however, have incurable problems. They are outrageously corrupt — and citizens know it — because they govern by paying off favored supporters, such as Russia’s oligarchs. Massive capital flight sucks out funds that should be invested domestically, not in New York or Palm Beach real estate. Competing factions struggle behind the scenes. Without rules, leadership successions turn nasty. Large state sectors tend to economic rigidity and misinvestment, sapping growth. Provincial officials report glowing economic conditions, sometimes producing catastrophe (mass starvation under Mao). Regimes can control social media but not whispers.

The authoritarians’ disinformation campaigns are no hoax. Russian intelligence is reportedly eager for 2020, but the White House says nothing. Are U.S. defenses sufficient? Can we form a united front with allies? Will social media delete “inauthentic posts” before they go viral? Could cyberwarfare escalate to kinetic warfare? How do we educate citizens and the media to doubt messages that confirm their biases?